expr.c (3e21a28a01e227726456a51933ed004c2df31850) expr.c (ff1a12f962dff5b490c5ce1c2c4bcd0bf3bf517d)
1// SPDX-License-Identifier: GPL-2.0
2#include "util/debug.h"
3#include "util/expr.h"
4#include "tests.h"
5#include <stdlib.h>
6#include <string.h>
7#include <linux/zalloc.h>
8

--- 27 unchanged lines hidden (view full) ---

36 ret |= test(&ctx, "1-1 & 1", 0);
37 ret |= test(&ctx, "min(1,2) + 1", 2);
38 ret |= test(&ctx, "max(1,2) + 1", 3);
39 ret |= test(&ctx, "1+1 if 3*4 else 0", 2);
40 ret |= test(&ctx, "1.1 + 2.1", 3.2);
41 ret |= test(&ctx, ".1 + 2.", 2.1);
42 ret |= test(&ctx, "d_ratio(1, 2)", 0.5);
43 ret |= test(&ctx, "d_ratio(2.5, 0)", 0);
1// SPDX-License-Identifier: GPL-2.0
2#include "util/debug.h"
3#include "util/expr.h"
4#include "tests.h"
5#include <stdlib.h>
6#include <string.h>
7#include <linux/zalloc.h>
8

--- 27 unchanged lines hidden (view full) ---

36 ret |= test(&ctx, "1-1 & 1", 0);
37 ret |= test(&ctx, "min(1,2) + 1", 2);
38 ret |= test(&ctx, "max(1,2) + 1", 3);
39 ret |= test(&ctx, "1+1 if 3*4 else 0", 2);
40 ret |= test(&ctx, "1.1 + 2.1", 3.2);
41 ret |= test(&ctx, ".1 + 2.", 2.1);
42 ret |= test(&ctx, "d_ratio(1, 2)", 0.5);
43 ret |= test(&ctx, "d_ratio(2.5, 0)", 0);
44 ret |= test(&ctx, "1.1 < 2.2", 1);
45 ret |= test(&ctx, "2.2 > 1.1", 1);
46 ret |= test(&ctx, "1.1 < 1.1", 0);
47 ret |= test(&ctx, "2.2 > 2.2", 0);
48 ret |= test(&ctx, "2.2 < 1.1", 0);
49 ret |= test(&ctx, "1.1 > 2.2", 0);
44
45 if (ret)
46 return ret;
47
48 p = "FOO/0";
49 ret = expr__parse(&val, &ctx, p, 1);
50 TEST_ASSERT_VAL("division by zero", ret == -1);
51

--- 30 unchanged lines hidden ---
50
51 if (ret)
52 return ret;
53
54 p = "FOO/0";
55 ret = expr__parse(&val, &ctx, p, 1);
56 TEST_ASSERT_VAL("division by zero", ret == -1);
57

--- 30 unchanged lines hidden ---