use GLib.Test framework for testing

This commit is contained in:
Chris Cromer 2019-01-15 16:54:00 -03:00
parent ac4338a57c
commit 346be0e9ac
Signed by: cromer
GPG Key ID: 39CC813FF3C8708A
3 changed files with 51 additions and 30 deletions

View File

@ -1,8 +1,15 @@
using LibSernatur.Misc; using LibSernatur.Misc;
public static int main (string[] args) { void add_money_tests () {
Test.add_func ("/sernatur/test/money", () => {
assert (Money.format_int (100000) == "$100.000"); assert (Money.format_int (100000) == "$100.000");
assert (Money.format_uint (100000) == "$100.000"); assert (Money.format_uint (100000) == "$100.000");
assert (Money.format_string ("100000") == "$100.000"); assert (Money.format_string ("100000") == "$100.000");
return 0; });
}
int main (string[] args) {
Test.init (ref args);
add_money_tests ();
return Test.run ();
} }

View File

@ -1,9 +1,16 @@
using LibSernatur.Misc; using LibSernatur.Misc;
public static int main (string[] args) { void add_percentage_tests () {
Test.add_func ("/sernatur/test/percentage", () => {
assert (Percentage.format_float ((float) 0.43) == "43%"); assert (Percentage.format_float ((float) 0.43) == "43%");
assert (Percentage.format_float ((float) 1) == "100%"); assert (Percentage.format_float ((float) 1) == "100%");
assert (Percentage.format_double (0.43) == "43%"); assert (Percentage.format_double (0.43) == "43%");
assert (Percentage.format_double (1) == "100%"); assert (Percentage.format_double (1) == "100%");
return 0; });
}
int main (string[] args) {
Test.init (ref args);
add_percentage_tests ();
return Test.run ();
} }

View File

@ -1,6 +1,7 @@
using LibSernatur.Misc; using LibSernatur.Misc;
public static int main (string[] args) { void add_rut_tests () {
Test.add_func ("/sernatur/test/rut", () => {
try { try {
Rut rut = new Rut ("18166316-2"); Rut rut = new Rut ("18166316-2");
assert (rut.get_clean_rut () == "181663162"); assert (rut.get_clean_rut () == "181663162");
@ -20,5 +21,11 @@ public static int main (string[] args) {
catch (Error e) { catch (Error e) {
error (e.message); error (e.message);
} }
return 0; });
}
int main (string[] args) {
Test.init (ref args);
add_rut_tests ();
return Test.run ();
} }