Skip to content

Commit

Permalink
test: split tst.str_comparison-basic.d into with and without NULL tes…
Browse files Browse the repository at this point in the history
…ting

Since NULL strings are not supported yet, the tst.str_comparison-basic.d
test is failing even though the non-NULL case should PASS without any
problem.  The test is now written as two tests: one that exercises the
case of NULL strings and one that does not.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Reviewed-by: Eugene Loh <eugene.loh@oracle.com>
  • Loading branch information
kvanhees committed Oct 27, 2022
1 parent 6d5cf4f commit 7ae3960
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 23 deletions.
75 changes: 75 additions & 0 deletions test/unittest/operators/tst.str_comparison-basic-with-NULL.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Oracle Linux DTrace.
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
/* @@xfail: No support for NULL strings yet */

/*
* ASSERTION: String comparisons work.
*
* SECTION: Operators
*/

#pragma D option quiet

BEGIN
{
nerrors = 0;

s1 = "abcdefghi";
s2 = "jklmnopqr";
s3 = "stuvwxyz!";

nerrors += (s1 <= s2 ? 0 : 1);
nerrors += (s1 < s2 ? 0 : 1);
nerrors += (s1 == s2 ? 1 : 0);
nerrors += (s1 != s2 ? 0 : 1);
nerrors += (s1 >= s2 ? 1 : 0);
nerrors += (s1 > s2 ? 1 : 0);

nerrors += (s2 <= s2 ? 0 : 1);
nerrors += (s2 < s2 ? 1 : 0);
nerrors += (s2 == s2 ? 0 : 1);
nerrors += (s2 != s2 ? 1 : 0);
nerrors += (s2 >= s2 ? 0 : 1);
nerrors += (s2 > s2 ? 1 : 0);

nerrors += (s3 <= s2 ? 1 : 0);
nerrors += (s3 < s2 ? 1 : 0);
nerrors += (s3 == s2 ? 1 : 0);
nerrors += (s3 != s2 ? 0 : 1);
nerrors += (s3 >= s2 ? 0 : 1);
nerrors += (s3 > s2 ? 0 : 1);

s2 = NULL;
nerrors += (s3 <= s2 ? 1 : 0);
nerrors += (s3 < s2 ? 1 : 0);
nerrors += (s3 == s2 ? 1 : 0);
nerrors += (s3 != s2 ? 0 : 1);
nerrors += (s3 >= s2 ? 0 : 0);
nerrors += (s3 > s2 ? 0 : 0);

nerrors += (s2 <= s3 ? 0 : 1);
nerrors += (s2 < s3 ? 0 : 1);
nerrors += (s2 == s3 ? 1 : 0);
nerrors += (s2 != s3 ? 0 : 1);
nerrors += (s2 >= s3 ? 1 : 0);
nerrors += (s2 > s3 ? 1 : 0);

s3 = NULL;
nerrors += (s2 <= s3 ? 0 : 1);
nerrors += (s2 < s3 ? 1 : 0);
nerrors += (s2 == s3 ? 0 : 1);
nerrors += (s2 != s3 ? 1 : 0);
nerrors += (s2 >= s3 ? 0 : 1);
nerrors += (s2 > s3 ? 1 : 0);

printf("%d errors\n", nerrors);
exit(nerrors == 0 ? 0 : 1);
}
ERROR
{
exit(1);
}
23 changes: 0 additions & 23 deletions test/unittest/operators/tst.str_comparison-basic.d
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,6 @@ BEGIN
nerrors += (s3 >= s2 ? 0 : 1);
nerrors += (s3 > s2 ? 0 : 1);

s2 = NULL;
nerrors += (s3 <= s2 ? 1 : 0);
nerrors += (s3 < s2 ? 1 : 0);
nerrors += (s3 == s2 ? 1 : 0);
nerrors += (s3 != s2 ? 0 : 1);
nerrors += (s3 >= s2 ? 0 : 0);
nerrors += (s3 > s2 ? 0 : 0);

nerrors += (s2 <= s3 ? 0 : 1);
nerrors += (s2 < s3 ? 0 : 1);
nerrors += (s2 == s3 ? 1 : 0);
nerrors += (s2 != s3 ? 0 : 1);
nerrors += (s2 >= s3 ? 1 : 0);
nerrors += (s2 > s3 ? 1 : 0);

s3 = NULL;
nerrors += (s2 <= s3 ? 0 : 1);
nerrors += (s2 < s3 ? 1 : 0);
nerrors += (s2 == s3 ? 0 : 1);
nerrors += (s2 != s3 ? 1 : 0);
nerrors += (s2 >= s3 ? 0 : 1);
nerrors += (s2 > s3 ? 1 : 0);

printf("%d errors\n", nerrors);
exit(nerrors == 0 ? 0 : 1);
}
Expand Down

0 comments on commit 7ae3960

Please sign in to comment.