[recipes] Update tests to build with new number code
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Update tests to build with new number code
- Date: Sun, 25 Jun 2017 03:30:22 +0000 (UTC)
commit 0fbbfac9a7b63658dcf7ede4c8e54b112b9c3715
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jun 24 23:15:17 2017 -0400
Update tests to build with new number code
The tests were expecting GrNumber. Some of the expected
output also changed due to minor changes in what
gr_number_format produces.
tests/ingredients-data/valid-1.expected | 6 +-
tests/ingredients-data/valid-2.expected | 4 +-
tests/ingredients-data/valid-3.expected | 2 +-
tests/ingredients-data/valid-4.expected | 16 ++--
tests/ingredients-test.c | 5 +-
tests/number-data/number1.expected | 142 +++++--------------------------
tests/number-data/number1.in | 2 +
tests/number.c | 9 +--
8 files changed, 42 insertions(+), 144 deletions(-)
---
diff --git a/tests/ingredients-data/valid-1.expected b/tests/ingredients-data/valid-1.expected
index f70f114..d64830c 100644
--- a/tests/ingredients-data/valid-1.expected
+++ b/tests/ingredients-data/valid-1.expected
@@ -1,12 +1,12 @@
-AMOUNT 1/1
+AMOUNT 1.000000
UNIT
NAME Apple
-AMOUNT 2/1
+AMOUNT 2.000000
UNIT
NAME Banana
-AMOUNT 3/1
+AMOUNT 3.000000
UNIT box
NAME nuts
diff --git a/tests/ingredients-data/valid-2.expected b/tests/ingredients-data/valid-2.expected
index a0c5d5e..8babca5 100644
--- a/tests/ingredients-data/valid-2.expected
+++ b/tests/ingredients-data/valid-2.expected
@@ -1,4 +1,4 @@
-AMOUNT 1/2
+AMOUNT 0.500000
UNIT lb
NAME Butter
@@ -6,7 +6,7 @@ AMOUNT 2.500000
UNIT
NAME Egg
-AMOUNT 15/1
+AMOUNT 15.000000
UNIT
NAME Salt
diff --git a/tests/ingredients-data/valid-3.expected b/tests/ingredients-data/valid-3.expected
index ff3dd3f..796403e 100644
--- a/tests/ingredients-data/valid-3.expected
+++ b/tests/ingredients-data/valid-3.expected
@@ -2,7 +2,7 @@ AMOUNT 2.123000
UNIT l
NAME Wine
-AMOUNT 1/2
+AMOUNT 0.500000
UNIT g
NAME nutmeg
diff --git a/tests/ingredients-data/valid-4.expected b/tests/ingredients-data/valid-4.expected
index 7da2bd2..a182681 100644
--- a/tests/ingredients-data/valid-4.expected
+++ b/tests/ingredients-data/valid-4.expected
@@ -1,32 +1,32 @@
-AMOUNT 1/1
+AMOUNT 1.000000
UNIT g
NAME Salt
-AMOUNT 2/1
+AMOUNT 2.000000
UNIT kg
NAME Salt
-AMOUNT 3/1
+AMOUNT 3.000000
UNIT l
NAME Wine
-AMOUNT 4/1
+AMOUNT 4.000000
UNIT l
NAME Milk
-AMOUNT 5/1
+AMOUNT 5.000000
UNIT l
NAME beer
-AMOUNT 1/1
+AMOUNT 1.000000
UNIT lb
NAME Ground beef
-AMOUNT 2/1
+AMOUNT 2.000000
UNIT lb
NAME meat
-AMOUNT 1/2
+AMOUNT 0.500000
UNIT box
NAME sticks
diff --git a/tests/ingredients-test.c b/tests/ingredients-test.c
index b7f7080..c4b55c2 100644
--- a/tests/ingredients-test.c
+++ b/tests/ingredients-test.c
@@ -54,10 +54,7 @@ test_file (const char *filename)
ingredients = gr_ingredients_list_new (contents);
for (l = ingredients->ingredients; l; l = l->next) {
Ingredient *ing = (Ingredient *)l->data;
- if (ing->amount.fraction)
- g_string_append_printf (string, "AMOUNT %d/%d\n", ing->amount.num,
ing->amount.denom);
- else
- g_string_append_printf (string, "AMOUNT %f\n", ing->amount.value);
+ g_string_append_printf (string, "AMOUNT %f\n", ing->amount);
g_string_append_printf (string, "UNIT %s\n", ing->unit);
g_string_append_printf (string, "NAME %s\n", ing->name);
g_string_append_printf (string, "\n");
diff --git a/tests/number-data/number1.expected b/tests/number-data/number1.expected
index 7db3f4b..ac2bd44 100644
--- a/tests/number-data/number1.expected
+++ b/tests/number-data/number1.expected
@@ -1,282 +1,187 @@
INPUT '123'
REST ''
-FRACTION 1
-NUMERATOR 123
-DENOMINATOR 1
VALUE 123
FORMATTED '123'
INPUT '123/201'
REST ''
-FRACTION 1
-NUMERATOR 41
-DENOMINATOR 67
VALUE 0.61194
-FORMATTED '41/67'
+FORMATTED '¹¹⁄₁₈'
INPUT '10.11'
REST ''
-FRACTION 0
-NUMERATOR 0
-DENOMINATOR 0
VALUE 10.11
-FORMATTED '10.11'
+FORMATTED '10 ⅑'
INPUT '-0.001'
REST ''
-FRACTION 0
-NUMERATOR 0
-DENOMINATOR 0
VALUE -0.001
-FORMATTED '-0.001'
+FORMATTED '-1 ¹⁄₁'
+
+INPUT '1/1'
+REST ''
+VALUE 1
+FORMATTED '1'
INPUT '1/2'
REST ''
-FRACTION 1
-NUMERATOR 1
-DENOMINATOR 2
VALUE 0.5
FORMATTED '½'
INPUT '1/3'
REST ''
-FRACTION 1
-NUMERATOR 1
-DENOMINATOR 3
VALUE 0.333333
FORMATTED '⅓'
INPUT '2/6'
REST ''
-FRACTION 1
-NUMERATOR 1
-DENOMINATOR 3
VALUE 0.333333
FORMATTED '⅓'
INPUT '1/0'
REST ''
-FRACTION 1
-NUMERATOR 1
-DENOMINATOR 0
-VALUE inf
-FORMATTED ''
+VALUE 1
+FORMATTED '1'
+
+INPUT '-1/1'
+REST ''
+VALUE -1
+FORMATTED '-1'
INPUT '1/-1'
REST ''
-FRACTION 1
-NUMERATOR -1
-DENOMINATOR 1
VALUE -1
FORMATTED '-1'
INPUT '-3/-4'
REST ''
-FRACTION 1
-NUMERATOR 3
-DENOMINATOR 4
VALUE 0.75
FORMATTED '¾'
INPUT '¼'
REST ''
-FRACTION 1
-NUMERATOR 1
-DENOMINATOR 4
VALUE 0.25
FORMATTED '¼'
INPUT '½'
REST ''
-FRACTION 1
-NUMERATOR 1
-DENOMINATOR 2
VALUE 0.5
FORMATTED '½'
INPUT '¾'
REST ''
-FRACTION 1
-NUMERATOR 3
-DENOMINATOR 4
VALUE 0.75
FORMATTED '¾'
INPUT '⅐'
REST ''
-FRACTION 1
-NUMERATOR 1
-DENOMINATOR 7
VALUE 0.142857
FORMATTED '⅐'
INPUT '⅑'
REST ''
-FRACTION 1
-NUMERATOR 1
-DENOMINATOR 9
VALUE 0.111111
FORMATTED '⅑'
INPUT '⅒'
REST ''
-FRACTION 1
-NUMERATOR 1
-DENOMINATOR 10
VALUE 0.1
FORMATTED '⅒'
INPUT '⅓'
REST ''
-FRACTION 1
-NUMERATOR 1
-DENOMINATOR 3
VALUE 0.333333
FORMATTED '⅓'
INPUT '⅔'
REST ''
-FRACTION 1
-NUMERATOR 2
-DENOMINATOR 3
VALUE 0.666667
FORMATTED '⅔'
INPUT '⅕'
REST ''
-FRACTION 1
-NUMERATOR 1
-DENOMINATOR 5
VALUE 0.2
FORMATTED '⅕'
INPUT '⅖'
REST ''
-FRACTION 1
-NUMERATOR 2
-DENOMINATOR 5
VALUE 0.4
FORMATTED '⅖'
INPUT '⅗'
REST ''
-FRACTION 1
-NUMERATOR 3
-DENOMINATOR 5
VALUE 0.6
FORMATTED '⅗'
INPUT '⅘'
REST ''
-FRACTION 1
-NUMERATOR 4
-DENOMINATOR 5
VALUE 0.8
FORMATTED '⅘'
INPUT '⅙'
REST ''
-FRACTION 1
-NUMERATOR 1
-DENOMINATOR 6
VALUE 0.166667
FORMATTED '⅙'
INPUT '⅚'
REST ''
-FRACTION 1
-NUMERATOR 5
-DENOMINATOR 6
VALUE 0.833333
FORMATTED '⅚'
INPUT '⅛'
REST ''
-FRACTION 1
-NUMERATOR 1
-DENOMINATOR 8
VALUE 0.125
FORMATTED '⅛'
INPUT '⅜'
REST ''
-FRACTION 1
-NUMERATOR 3
-DENOMINATOR 8
VALUE 0.375
FORMATTED '⅜'
INPUT '⅝'
REST ''
-FRACTION 1
-NUMERATOR 5
-DENOMINATOR 8
VALUE 0.625
FORMATTED '⅝'
INPUT '⅞'
REST ''
-FRACTION 1
-NUMERATOR 7
-DENOMINATOR 8
VALUE 0.875
FORMATTED '⅞'
INPUT '1 1/2'
REST ''
-FRACTION 1
-NUMERATOR 3
-DENOMINATOR 2
VALUE 1.5
-FORMATTED '1 ½'
+FORMATTED '1 ½'
INPUT '2 23/47'
REST ''
-FRACTION 1
-NUMERATOR 117
-DENOMINATOR 47
VALUE 2.48936
-FORMATTED '2 23/47'
+FORMATTED '2 ½'
INPUT '1 ¼'
REST ''
-FRACTION 1
-NUMERATOR 5
-DENOMINATOR 4
VALUE 1.25
-FORMATTED '1 ¼'
+FORMATTED '1 ¼'
INPUT '2 ½'
REST ''
-FRACTION 1
-NUMERATOR 5
-DENOMINATOR 2
VALUE 2.5
-FORMATTED '2 ½'
+FORMATTED '2 ½'
INPUT '1 ½'
REST ''
-FRACTION 1
-NUMERATOR 3
-DENOMINATOR 2
VALUE 1.5
-FORMATTED '1 ½'
+FORMATTED '1 ½'
INPUT '1¼'
REST ''
-FRACTION 1
-NUMERATOR 5
-DENOMINATOR 4
VALUE 1.25
-FORMATTED '1 ¼'
+FORMATTED '1 ¼'
INPUT '2½'
REST ''
-FRACTION 1
-NUMERATOR 5
-DENOMINATOR 2
VALUE 2.5
-FORMATTED '2 ½'
+FORMATTED '2 ½'
INPUT '10.11.12'
REST '10.11.12'
@@ -292,9 +197,6 @@ ERROR Could not parse --2 as a number
INPUT '10 11.12'
REST ' 11.12'
-FRACTION 1
-NUMERATOR 10
-DENOMINATOR 1
VALUE 10
FORMATTED '10'
diff --git a/tests/number-data/number1.in b/tests/number-data/number1.in
index 91a7d7c..eaf2290 100644
--- a/tests/number-data/number1.in
+++ b/tests/number-data/number1.in
@@ -3,10 +3,12 @@
123/201
10.11
-0.001
+1/1
1/2
1/3
2/6
1/0
+-1/1
1/-1
-3/-4
diff --git a/tests/number.c b/tests/number.c
index 0dae5ef..f0f2b5a 100644
--- a/tests/number.c
+++ b/tests/number.c
@@ -31,7 +31,7 @@ static GString *string;
static void
test_line (const char *line)
{
- GrNumber number;
+ double number;
char *input;
g_autoptr(GError) error = NULL;
@@ -45,13 +45,10 @@ test_line (const char *line)
else {
g_autofree char *formatted;
- formatted = gr_number_format (&number);
+ formatted = gr_number_format (number);
g_string_append_printf (string, "REST '%s'\n", input);
- g_string_append_printf (string, "FRACTION %d\n", number.fraction);
- g_string_append_printf (string, "NUMERATOR %d\n", number.num);
- g_string_append_printf (string, "DENOMINATOR %d\n", number.denom);
- g_string_append_printf (string, "VALUE %g\n", number.value);
+ g_string_append_printf (string, "VALUE %g\n", number);
g_string_append_printf (string, "FORMATTED '%s'\n", formatted);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]