MCPcopy Create free account
hub / github.com/davisking/dlib / test_optional_int_constexpr

Function test_optional_int_constexpr

dlib/test/optional.cpp:211–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209// ---------------------------------------------------------------------------------------------------
210
211 void test_optional_int_constexpr()
212 {
213 {
214 constexpr dlib::optional<int> o2{};
215 constexpr dlib::optional<int> o3 = {};
216 constexpr dlib::optional<int> o4 = dlib::nullopt;
217 constexpr dlib::optional<int> o5 = {dlib::nullopt};
218 constexpr dlib::optional<int> o6(dlib::nullopt);
219
220 static_assert(!o2, "bad");
221 static_assert(!o3, "bad");
222 static_assert(!o4, "bad");
223 static_assert(!o5, "bad");
224 static_assert(!o6, "bad");
225
226 static_assert(o2.value_or(1) == 1, "bad");
227 static_assert(o3.value_or(1) == 1, "bad");
228 static_assert(o4.value_or(1) == 1, "bad");
229 static_assert(o5.value_or(1) == 1, "bad");
230 static_assert(o6.value_or(1) == 1, "bad");
231
232 static_assert(o2 != 1, "bad");
233 static_assert(1 != o2, "bad");
234 }
235 }
236
237// ---------------------------------------------------------------------------------------------------
238

Callers 1

perform_testMethod · 0.85

Calls 1

value_orMethod · 0.80

Tested by

no test coverage detected