Debian Codegraph @

debian/patches/0005-tests-Fix-double-value-comparison-error-on-i386.patch

raw symbols SCIP
1 Fromscip-debian debian marisa 0.3.1+git20250817-1 marisa/patches/`0005-tests-Fix-double-value-comparison-error-on-i386.patch`#From.: Boyuan Yang <[email protected]scip-debian . . . identity/`[email protected]`.>
2 Datescip-debian debian marisa 0.3.1+git20250817-1 marisa/patches/`0005-tests-Fix-double-value-comparison-error-on-i386.patch`#Date.: Tue, 23 Sep 2025 09:09:53 -0400
3 Subjectscip-debian debian marisa 0.3.1+git20250817-1 marisa/patches/`0005-tests-Fix-double-value-comparison-error-on-i386.patch`#Subject.: tests/: Fix double value comparison error on i386
4
5 Forwarded: https://github.com/s-yata/marisa-trie/issues/127
6 ---
7 tests/base-test.cc | 17 -----------------
8 tests/io-test.cc | 24 ++++++++++++------------
9 tests/marisa-assert.h | 4 ++++
10 3 files changed, 16 insertions(+), 29 deletions(-)
11
12 diff --git a/tests/base-test.ccscip-debian debian marisa 0.3.1+git20250817-1 marisa/upstream/`tests/base-test.cc`: b/tests/base-test.ccscip-debian debian marisa 0.3.1+git20250817-1 marisa/upstream/`tests/base-test.cc`:
13 index 2f1cfe8..bb4554d 100644
14 --- a/tests/base-test.cc
15 +++ b/tests/base-test.cc
16 @@ -17,22 +17,6 @@ namespace {
17 std::random_device seed_gen;
18 std::mt19937 random_engine(seed_gen());
19
20 -void TestSwap() {
21 - TEST_START();
22 -
23 - int x = 100, y = 200;
24 - std::swap(x, y);
25 - ASSERT(x == 200);
26 - ASSERT(y == 100);
27 -
28 - double a = 1.23, b = 2.34;
29 - std::swap(a, b);
30 - ASSERT(a == 2.34);
31 - ASSERT(b == 1.23);
32 -
33 - TEST_END();
34 -}
35 -
36 void TestException() {
37 TEST_START();
38
39 @@ -333,7 +317,6 @@ void TestAgent() {
40 } // namespace
41
42 int main() try {
43 - TestSwap();
44 TestException();
45 TestKey();
46 TestKeyset();
47 diff --git a/tests/io-test.ccscip-debian debian marisa 0.3.1+git20250817-1 marisa/upstream/`tests/io-test.cc`: b/tests/io-test.ccscip-debian debian marisa 0.3.1+git20250817-1 marisa/upstream/`tests/io-test.cc`:
48 index 668df5a..7381241 100644
49 --- a/tests/io-test.cc
50 +++ b/tests/io-test.cc
51 @@ -46,8 +46,8 @@ void TestFilename() {
52
53 double values[2];
54 reader.read(values, 2);
55 - ASSERT(values[0] == 3.45);
56 - ASSERT(values[1] == 4.56);
57 + ASSERT_DOUBLE_EQ(values[0], 3.45);
58 + ASSERT_DOUBLE_EQ(values[1], 4.56);
59
60 char byte;
61 EXCEPT(reader.read(&byte), std::runtime_error);
62 @@ -65,8 +65,8 @@ void TestFilename() {
63
64 const double *values;
65 mapper.map(&values, 2);
66 - ASSERT(values[0] == 3.45);
67 - ASSERT(values[1] == 4.56);
68 + ASSERT_DOUBLE_EQ(values[0], 3.45);
69 + ASSERT_DOUBLE_EQ(values[1], 4.56);
70
71 char byte;
72 EXCEPT(mapper.map(&byte), std::runtime_error);
73 @@ -84,8 +84,8 @@ void TestFilename() {
74
75 const double *values;
76 mapper.map(&values, 2);
77 - ASSERT(values[0] == 3.45);
78 - ASSERT(values[1] == 4.56);
79 + ASSERT_DOUBLE_EQ(values[0], 3.45);
80 + ASSERT_DOUBLE_EQ(values[1], 4.56);
81
82 char byte;
83 EXCEPT(mapper.map(&byte), std::runtime_error);
84 @@ -154,8 +154,8 @@ void TestFd() {
85
86 double values[2];
87 reader.read(values, 2);
88 - ASSERT(values[0] == 34.5);
89 - ASSERT(values[1] == 67.8);
90 + ASSERT_DOUBLE_EQ(values[0], 34.5);
91 + ASSERT_DOUBLE_EQ(values[1], 67.8);
92
93 char byte;
94 EXCEPT(reader.read(&byte), std::runtime_error);
95 @@ -210,8 +210,8 @@ void TestFile() {
96
97 double values[2];
98 reader.read(values, 2);
99 - ASSERT(values[0] == 0.1);
100 - ASSERT(values[1] == 0.2);
101 + ASSERT_DOUBLE_EQ(values[0], 0.1);
102 + ASSERT_DOUBLE_EQ(values[1], 0.2);
103
104 char byte;
105 EXCEPT(reader.read(&byte), std::runtime_error);
106 @@ -248,8 +248,8 @@ void TestStream() {
107
108 double values[2];
109 reader.read(values, 2);
110 - ASSERT(values[0] == 3.4);
111 - ASSERT(values[1] == 5.6);
112 + ASSERT_DOUBLE_EQ(values[0], 3.4);
113 + ASSERT_DOUBLE_EQ(values[1], 5.6);
114
115 char byte;
116 EXCEPT(reader.read(&byte), std::runtime_error);
117 diff --git a/tests/marisa-assert.hscip-debian debian marisa 0.3.1+git20250817-1 marisa/upstream/`tests/marisa-assert.h`: b/tests/marisa-assert.hscip-debian debian marisa 0.3.1+git20250817-1 marisa/upstream/`tests/marisa-assert.h`:
118 index 2aa9152..a2dab4f 100644
119 --- a/tests/marisa-assert.h
120 +++ b/tests/marisa-assert.h
121 @@ -3,12 +3,16 @@
122
123 #include <cstdlib>
124 #include <iostream>
125 +#include <cmath>
126
127 #define ASSERT(cond) \
128 (void)((!!(cond)) || ((std::cout << __LINE__ << ": Assertion `" << #cond \
129 << "' failed.\n"), \
130 std::exit(-1), 0))
131
132 +#define ASSERT_DOUBLE_EQ(actual, expected) \
133 + ASSERT(std::abs((actual) - (expected)) < 1e-14)
134 +
135 #define EXCEPT(code, expected_error_type) \
136 try { \
137 code; \