Skip to content

Commit 2baddc7

Browse files
Add axioms for bool <-> int GfNumericCasts in testGfHardToReach
1 parent 8db0cb2 commit 2baddc7

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

pxr/base/gf/testenv/testGfHardToReach.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,29 @@ main(int argc, char *argv[])
252252
static_cast<float>(
253253
std::numeric_limits<int16_t>::lowest()) - 1.0f,
254254
&failType) && failType == GfNumericCastNegOverflow);
255+
256+
// bool -> int
257+
TF_AXIOM(GfNumericCast<int>(true).value() == 1);
258+
TF_AXIOM(GfNumericCast<int>(false).value() == 0);
259+
260+
// int -> bool
261+
TF_AXIOM(GfNumericCast<bool>(0).value() == false);
262+
TF_AXIOM(GfNumericCast<bool>(1).value() == true);
263+
264+
TF_AXIOM(!GfNumericCast<bool>(-1, &failType) &&
265+
failType == GfNumericCastNegOverflow);
266+
267+
TF_AXIOM(!GfNumericCast<bool>(2, &failType) &&
268+
failType == GfNumericCastPosOverflow);
269+
270+
TF_AXIOM(GfNumericCast<bool>(static_cast<unsigned>(0)).value() == false);
271+
TF_AXIOM(GfNumericCast<bool>(static_cast<unsigned>(1)).value() == true);
272+
273+
TF_AXIOM(!GfNumericCast<bool>(static_cast<unsigned>(2), &failType) &&
274+
failType == GfNumericCastPosOverflow);
275+
276+
TF_AXIOM(!GfNumericCast<bool>(std::numeric_limits<unsigned>::max(), &failType) &&
277+
failType == GfNumericCastPosOverflow);
255278

256279
// unsigned
257280
TF_AXIOM(GfNumericCast<uint16_t>(

0 commit comments

Comments
 (0)