[gnome-calculator/60-split-out-a-backend-library] gcalc: added tests for terms as variables and constants
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calculator/60-split-out-a-backend-library] gcalc: added tests for terms as variables and constants
- Date: Thu, 3 Jan 2019 16:58:29 +0000 (UTC)
commit 81b732365f12cc58db5cd6dacc8e04a382aa5a7d
Author: Daniel Espinosa Ortiz <esodan gmail com>
Date: Thu Jan 3 09:43:22 2019 -0600
gcalc: added tests for terms as variables and constants
tests/gcalc-main-interfaces.vala | 58 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
---
diff --git a/tests/gcalc-main-interfaces.vala b/tests/gcalc-main-interfaces.vala
index cc0b279d..5339b95b 100644
--- a/tests/gcalc-main-interfaces.vala
+++ b/tests/gcalc-main-interfaces.vala
@@ -164,6 +164,64 @@ class Tests {
warning ("Error: %s", error.message);
}
});
+ Test.add_func ("/gcalc/parser/term/plus/variables+constant",
+ ()=>{
+ try {
+ var parser = new Parser ();
+ var eqman = new GMathEquationManager ();
+ parser.parse ("A+1", eqman);
+ assert (eqman.equations.get_n_items () == 1);
+ var eq = eqman.equations.get_item (0) as MathEquation;
+ assert (eq != null);
+ assert (eq.expressions.get_n_items () == 1);
+ var p = eq.expressions.get_item (0) as Polynomial;
+ assert (p != null);
+ assert (p.expressions.get_n_items () == 2);
+ var t1 = p.expressions.get_item (0) as Term;
+ assert (t1 != null);
+ assert (t1.expressions.get_n_items () == 1);
+ var c1 = t1.expressions.get_item (0) as Variable;
+ assert (c1 != null);
+ var t2 = p.expressions.get_item (1) as Term;
+ assert (t2 != null);
+ assert (t2.expressions.get_n_items () == 2);
+ var plus = t2.expressions.get_item (0) as Plus;
+ assert (plus != null);
+ var c2 = t2.expressions.get_item (1) as Constant;
+ assert (c2 != null);
+ } catch (GLib.Error error) {
+ warning ("Error: %s", error.message);
+ }
+ });
+ Test.add_func ("/gcalc/parser/term/plus/constant+variable",
+ ()=>{
+ try {
+ var parser = new Parser ();
+ var eqman = new GMathEquationManager ();
+ parser.parse ("1+B", eqman);
+ assert (eqman.equations.get_n_items () == 1);
+ var eq = eqman.equations.get_item (0) as MathEquation;
+ assert (eq != null);
+ assert (eq.expressions.get_n_items () == 1);
+ var p = eq.expressions.get_item (0) as Polynomial;
+ assert (p != null);
+ assert (p.expressions.get_n_items () == 2);
+ var t1 = p.expressions.get_item (0) as Term;
+ assert (t1 != null);
+ assert (t1.expressions.get_n_items () == 1);
+ var c1 = t1.expressions.get_item (0) as Constant;
+ assert (c1 != null);
+ var t2 = p.expressions.get_item (1) as Term;
+ assert (t2 != null);
+ assert (t2.expressions.get_n_items () == 2);
+ var plus = t2.expressions.get_item (0) as Plus;
+ assert (plus != null);
+ var c2 = t2.expressions.get_item (1) as Variable;
+ assert (c2 != null);
+ } catch (GLib.Error error) {
+ warning ("Error: %s", error.message);
+ }
+ });
return Test.run ();
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]