test_param.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2021 The urg_stamped Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <gtest/gtest.h>
18 
19 #include <string>
20 
21 #include <scip2/param.h>
22 
23 TEST(ParseParamLine, parsed)
24 {
25  // Checksum example shown in SCIP2.0 Specification
26  const std::string line("PROT:SCIP 2.0;N");
28  ASSERT_EQ(true, p.parsed) << p.error;
29  ASSERT_EQ(true, p.checksum_matched);
30  ASSERT_EQ("PROT", p.key);
31  ASSERT_EQ("SCIP 2.0", p.value);
32 }
33 
34 TEST(ParseParamLine, shortLine)
35 {
36  const std::string line(";");
38  ASSERT_EQ(false, p.parsed);
39 }
40 
41 TEST(ParseParamLine, noDelimiter)
42 {
43  const std::string line("PROT+SCIP 2.0;N");
45  ASSERT_EQ(false, p.parsed);
46 }
47 
48 TEST(ParseParamLine, noChecksumDelimiter)
49 {
50  const std::string line("PROT:SCIP 2.0");
52  ASSERT_EQ(false, p.parsed);
53 }
54 TEST(ParseParamLine, checksumMismatch)
55 {
56  const std::string line("PROT:SCIP 2.0;X");
58  ASSERT_EQ(true, p.parsed) << p.error;
59  ASSERT_EQ(false, p.checksum_matched);
60  ASSERT_EQ("PROT", p.key);
61  ASSERT_EQ("SCIP 2.0", p.value);
62 }
63 
64 TEST(ParseParamLine, containsSemicolon)
65 {
66  const std::string line("TIME:j;o[;H");
68  ASSERT_EQ(true, p.parsed) << p.error;
69  ASSERT_EQ(true, p.checksum_matched);
70  ASSERT_EQ("TIME", p.key);
71  ASSERT_EQ("j;o[", p.value);
72 }
73 
74 int main(int argc, char** argv)
75 {
76  testing::InitGoogleTest(&argc, argv);
77 
78  return RUN_ALL_TESTS();
79 }
scip2::ParsedParam::key
std::string key
Definition: param.h:30
scip2::ParsedParam::value
std::string value
Definition: param.h:31
main
int main(int argc, char **argv)
Definition: test_param.cpp:74
scip2::ParsedParam::error
std::string error
Definition: param.h:32
scip2::parseParamLine
static ParsedParam parseParamLine(const std::string &line)
Definition: param.h:41
param.h
scip2::ParsedParam::parsed
bool parsed
Definition: param.h:28
scip2::ParsedParam
Definition: param.h:26
scip2::ParsedParam::checksum_matched
bool checksum_matched
Definition: param.h:29
TEST
TEST(ParseParamLine, parsed)
Definition: test_param.cpp:23


urg_stamped
Author(s): Atsushi Watanabe
autogenerated on Wed Dec 18 2024 03:10:57