ProteoWizard
Main Page
Namespaces
Classes
Files
File List
File Members
pwiz
data
common
CVTranslatorTest.cpp
Go to the documentation of this file.
1
//
2
// $Id: CVTranslatorTest.cpp 4129 2012-11-20 00:05:37Z chambm $
3
//
4
//
5
// Original author: Darren Kessner <darren@proteowizard.org>
6
//
7
// Copyright 2008 Spielberg Family Center for Applied Proteomics
8
// Cedars-Sinai Medical Center, Los Angeles, California 90048
9
//
10
// Licensed under the Apache License, Version 2.0 (the "License");
11
// you may not use this file except in compliance with the License.
12
// You may obtain a copy of the License at
13
//
14
// http://www.apache.org/licenses/LICENSE-2.0
15
//
16
// Unless required by applicable law or agreed to in writing, software
17
// distributed under the License is distributed on an "AS IS" BASIS,
18
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
// See the License for the specific language governing permissions and
20
// limitations under the License.
21
//
22
23
24
#include "
CVTranslator.hpp
"
25
#include "
pwiz/utility/misc/unit.hpp
"
26
#include "
pwiz/utility/misc/Std.hpp
"
27
#include <cstring>
28
29
30
using namespace
pwiz::util;
31
using namespace
pwiz::cv
;
32
using namespace
pwiz::data;
33
34
35
ostream*
os_
= 0;
36
37
38
void
test
(
const
CVTranslator
& translator,
const
string
& text, CVID correct)
39
{
40
CVID result = translator.
translate
(text);
41
if
(
os_
) *
os_
<< text <<
" -> ("
<<
cvTermInfo
(result).
id
<<
", \""
42
<<
cvTermInfo
(result).
name
<<
"\")\n"
;
43
unit_assert
(result == correct);
44
}
45
46
47
void
test
()
48
{
49
if
(
os_
) *
os_
<<
"test()\n"
;
50
51
CVTranslator
translator;
52
test
(translator,
"FT-ICR"
,
MS_FT_ICR
);
53
test
(translator,
" \nFT - \tICR\t"
,
MS_FT_ICR
);
54
test
(translator,
" Total \t\n iOn @#$CurRENT"
,
MS_TIC
);
55
56
unit_assert
(translator.
translate
(
"Darren Kessner"
) ==
CVID_Unknown
);
57
translator.
insert
(
"DARREN.#$@#$^KESSNER"
,
MS_software
);
58
test
(translator,
"dARren kESSner"
,
MS_software
);
59
60
// test collision detection
61
bool
caught =
false
;
62
try
63
{
64
translator.
insert
(
"darren kessner"
,
MS_m_z
);
65
}
66
catch
(exception& )
67
{
68
caught =
true
;
69
}
70
if
(
os_
) *
os_
<<
"collision caught: "
<< boolalpha << caught << endl;
71
unit_assert
(caught);
72
73
// test default extra entries
74
75
test
(translator,
" itms "
,
MS_ion_trap
);
76
test
(translator,
" FTmS\n"
,
MS_FT_ICR
);
77
}
78
79
80
int
main
(
int
argc,
char
* argv[])
81
{
82
TEST_PROLOG
(argc, argv)
83
84
try
85
{
86
if
(argc>1 && !strcmp(argv[1],
"-v"
))
os_
= &cout;
87
test
();
88
}
89
catch
(exception&
e
)
90
{
91
TEST_FAILED
(e.what())
92
}
93
catch
(...)
94
{
95
TEST_FAILED
(
"Caught unknown exception."
)
96
}
97
98
TEST_EPILOG
99
}
100
Generated on Mon Nov 26 2012 18:05:47 for ProteoWizard by
1.8.1.1