MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / test_getting

Function test_getting

tests/proto.cc:63–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63static void test_getting(void)
64{
65 std::string s = R"M(
66 i64: -1
67 i32: -2
68 u64: 3
69 u32: 4
70 d: 5.5
71 f: 6.7
72 m {
73 s: "string"
74 }
75 r {
76 s: "val2"
77 }
78 r {
79 s: "val3"
80 }
81 secondoption {
82 s: "2"
83 r: 0
84 r: 1
85 r: 2
86 }
87 )M";
88
89 TestProto tp;
90 if (!google::protobuf::TextFormat::MergeFromString(cleanup(s), &tp))
91 error("couldn't load test proto");
92
93 AssertThat(getProtoByString(&tp, "i64"), Equals("-1"));
94 AssertThat(getProtoByString(&tp, "i32"), Equals("-2"));
95 AssertThat(getProtoByString(&tp, "u64"), Equals("3"));
96 AssertThat(getProtoByString(&tp, "u32"), Equals("4"));
97 AssertThat(getProtoByString(&tp, "d"), Equals("5.5"));
98 AssertThat(getProtoByString(&tp, "f"), Equals("6.7"));
99 AssertThat(getProtoByString(&tp, "m.s"), Equals("string"));
100 AssertThat(getProtoByString(&tp, "r[0].s"), Equals("val2"));
101 AssertThat(getProtoByString(&tp, "r[1].s"), Equals("val3"));
102 AssertThrows(
103 ProtoPathNotFoundException, getProtoByString(&tp, "firstoption.s"));
104 AssertThat(getProtoByString(&tp, "secondoption.r[2]"), Equals("2"));
105 AssertThat(getProtoByString(&tp, "secondoption.s"), Equals("2"));
106}
107
108static void test_config(void)
109{

Callers 1

mainFunction · 0.85

Calls 3

errorFunction · 0.85
getProtoByStringFunction · 0.85
cleanupFunction · 0.70

Tested by

no test coverage detected