Browse Source

add unit testing

tags/1.0.0
Chris Cromer 10 months ago
parent
commit
8d1e27bd96
Signed by: Chris Cromer <chris@cromer.cl> GPG Key ID: 39CC813FF3C8708A
5 changed files with 68 additions and 0 deletions
  1. +1
    -0
      meson.build
  2. +20
    -0
      test/meson.build
  3. +10
    -0
      test/money.vala
  4. +11
    -0
      test/percentage.vala
  5. +26
    -0
      test/rut.vala

+ 1
- 0
meson.build View File

@@ -27,3 +27,4 @@ subdir('lib')
subdir('src')
subdir('doc')
subdir('script')
subdir('test')

+ 20
- 0
test/meson.build View File

@@ -0,0 +1,20 @@
money_test = executable('money',
'money.vala',
dependencies: [glib_dep, gobject_dep, gtk_dep, gmodule_dep, pq_dep, lib_dep],
install : false)

test('Money', money_test)

rut_test = executable('rut',
'rut.vala',
dependencies: [glib_dep, gobject_dep, gtk_dep, gmodule_dep, pq_dep, lib_dep],
install : false)

test('RUT', rut_test)

percentage_test = executable('percentage',
'percentage.vala',
dependencies: [glib_dep, gobject_dep, gtk_dep, gmodule_dep, pq_dep, lib_dep],
install : false)

test('Percentage', percentage_test)

+ 10
- 0
test/money.vala View File

@@ -0,0 +1,10 @@
namespace SernaturTest {
using LibSernatur.Misc;

public static int main (string[] args) {
assert (Money.format_int (100000) == "$100.000");
assert (Money.format_uint (100000) == "$100.000");
assert (Money.format_string ("100000") == "$100.000");
return 0;
}
}

+ 11
- 0
test/percentage.vala View File

@@ -0,0 +1,11 @@
namespace SernaturTest {
using LibSernatur.Misc;

public static int main (string[] args) {
assert (Percentage.format_float ((float) 0.43) == "43%");
assert (Percentage.format_float ((float) 1) == "100%");
assert (Percentage.format_double (0.43) == "43%");
assert (Percentage.format_double (1) == "100%");
return 0;
}
}

+ 26
- 0
test/rut.vala View File

@@ -0,0 +1,26 @@
namespace SernaturTest {
using LibSernatur.Misc;

public static int main (string[] args) {
try {
Rut rut = new Rut ("18166316-2");
assert (rut.get_clean_rut () == "181663162");
assert (rut.get_rut () == "18.166.316-2");
assert (rut.type () == Rut.Type.RUN);

rut = new Rut ("20380508-k");
assert (rut.get_clean_rut () == "20380508K");
assert (rut.get_rut () == "20.380.508-K");
assert (rut.type () == Rut.Type.RUN);

rut = new Rut ("50380508-1");
assert (rut.get_clean_rut () == "503805081");
assert (rut.get_rut () == "50.380.508-1");
assert (rut.type () == Rut.Type.RUT);
}
catch (Error e) {
error (e.message);
}
return 0;
}
}

Loading…
Cancel
Save