-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdivide.affine
More file actions
72 lines (63 loc) · 2.04 KB
/
Copy pathdivide.affine
File metadata and controls
72 lines (63 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// SPDX-License-Identifier: PMPL-1.0-or-later
// SPDX-FileCopyrightText: 2025 hyperpolymath
//
// Auto-generated conformance tests for aLib spec: arithmetic/divide
// Source: aggregate-library/specs/arithmetic/divide.md
//
// Conforms to aLib arithmetic/divide spec v1.0
/// Test: Basic division with exact result
fn test_divide_exact() -> TestResult {
let result = 6 / 2;
assert_eq(result, 3, "Basic division with exact result");
Pass
}
/// Test: Division with fractional result
fn test_divide_fractional() -> TestResult {
let result = 7.0 / 2.0;
assert_float_eq(result, 3.5, 0.0001, "Division with fractional result");
Pass
}
/// Test: Zero divided by non-zero
fn test_divide_zero() -> TestResult {
let result = 0 / 5;
assert_eq(result, 0, "Zero divided by non-zero");
Pass
}
/// Test: Division with negative dividend
fn test_divide_negative_dividend() -> TestResult {
let result = -10 / 2;
assert_eq(result, -5, "Division with negative dividend");
Pass
}
/// Test: Division with negative divisor
fn test_divide_negative_divisor() -> TestResult {
let result = 10 / -2;
assert_eq(result, -5, "Division with negative divisor");
Pass
}
/// Test: Division of two negative numbers
fn test_divide_two_negatives() -> TestResult {
let result = -12 / -3;
assert_eq(result, 4, "Division of two negative numbers");
Pass
}
/// Run all divide conformance tests
fn test_alib_arithmetic_divide() -> TestResult {
let suite = #{
name: "aLib arithmetic/divide conformance",
tests: [
#{ name: "divide_exact", test: test_divide_exact },
#{ name: "divide_fractional", test: test_divide_fractional },
#{ name: "divide_zero", test: test_divide_zero },
#{ name: "divide_negative_dividend", test: test_divide_negative_dividend },
#{ name: "divide_negative_divisor", test: test_divide_negative_divisor },
#{ name: "divide_two_negatives", test: test_divide_two_negatives }
]
};
let (passed, failed) = run_suite(suite);
if failed == 0 {
Pass
} else {
Fail("Some divide conformance tests failed")
}
}