Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Add unittest to make sure
Browse files Browse the repository at this point in the history
  • Loading branch information
andralex authored and RazvanN7 committed Feb 7, 2022
1 parent a36ddc7 commit ccb8a23
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/rt/util/typeinfo.d
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@ if (is(T == float) || is(T == double) || is(T == real))
return (d1 > d2) - !(d1 >= d2);
}

unittest
{
assert(cmp3(int.max, int.min) > 0);
double x, y;
assert(cmp3(x, y) == 0);
assert(cmp3(y, x) == 0);
x = 42;
assert(cmp3(x, y) > 0);
assert(cmp3(y, x) < 0);
y = 43;
assert(cmp3(x, y) < 0);
assert(cmp3(y, x) > 0);
y = 42;
assert(cmp3(x, y) == 0);
assert(cmp3(y, x) == 0);
}

// Three-way compare for complex types.
pragma(inline, true)
private int cmp3(T)(const T f1, const T f2)
Expand Down

0 comments on commit ccb8a23

Please sign in to comment.