Skip to content

Commit

Permalink
Use XOR for number comparison.
Browse files Browse the repository at this point in the history
For reason I do not want to debug, comparing after AND
gives different results on Windows and Unix.
  • Loading branch information
Rot127 committed Sep 1, 2024
1 parent e2a7803 commit 8507470
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions bindings/python/cstest_py/src/cstest_py/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def compare_uint8(actual: int, expected: None | int, msg: str) -> bool:

actual = actual & 0xFF
expected = expected & 0xFF
if actual != expected:
if actual ^ expected != 0:
log.error(f"{msg}: {actual} != {expected}")
return False
return True
Expand All @@ -187,7 +187,7 @@ def compare_int8(actual: int, expected: None | int, msg: str) -> bool:

actual = actual & 0xFF
expected = expected & 0xFF
if actual != expected:
if actual ^ expected != 0:
log.error(f"{msg}: {actual} != {expected}")
return False
return True
Expand All @@ -200,7 +200,7 @@ def compare_uint16(actual: int, expected: None | int, msg: str) -> bool:

actual = actual & 0xFFFF
expected = expected & 0xFFFF
if actual != expected:
if actual ^ expected != 0:
log.error(f"{msg}: {actual} != {expected}")
return False
return True
Expand All @@ -213,7 +213,7 @@ def compare_int16(actual: int, expected: None | int, msg: str) -> bool:

actual = actual & 0xFFFF
expected = expected & 0xFFFF
if actual != expected:
if actual ^ expected != 0:
log.error(f"{msg}: {actual} != {expected}")
return False
return True
Expand All @@ -226,7 +226,7 @@ def compare_uint32(actual: int, expected: None | int, msg: str) -> bool:

actual = actual & 0xFFFFFFFF
expected = expected & 0xFFFFFFFF
if actual != expected:
if actual ^ expected != 0:
log.error(f"{msg}: {actual} != {expected}")
return False
return True
Expand All @@ -239,7 +239,7 @@ def compare_int32(actual: int, expected: None | int, msg: str) -> bool:

actual = actual & 0xFFFFFFFF
expected = expected & 0xFFFFFFFF
if actual != expected:
if actual ^ expected != 0:
log.error(f"{msg}: {actual} != {expected}")
return False
return True
Expand All @@ -252,7 +252,7 @@ def compare_uint64(actual: int, expected: None | int, msg: str) -> bool:

actual = actual & 0xFFFFFFFFFFFFFFFF
expected = expected & 0xFFFFFFFFFFFFFFFF
if actual != expected:
if actual ^ expected != 0:
log.error(f"{msg}: {actual} != {expected}")
return False
return True
Expand All @@ -265,7 +265,7 @@ def compare_int64(actual: int, expected: None | int, msg: str) -> bool:

actual = actual & 0xFFFFFFFFFFFFFFFF
expected = expected & 0xFFFFFFFFFFFFFFFF
if actual != expected:
if actual ^ expected != 0:
log.error(f"{msg}: {actual} != {expected}")
return False
return True
Expand Down

0 comments on commit 8507470

Please sign in to comment.