/vqdr/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/vqdr/trunk

« back to all changes in this revision

Viewing changes to tests/libvee/named_vector.vala

  • Committer: Gustav Hartvigsson
  • Date: 2024-12-22 00:30:29 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20241222003029-k74ogrm32zobz325
[General] Split libvee into it's own library.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using Vee;
 
2
using GLib;
 
3
 
 
4
void named_vector_test () {
 
5
  Test.add_func (VEE_TEST_NAMED_VECTOR_PREFIX + "new", () => {
 
6
    var nv = new NamedVector<int> ("Hello,", 13, "world", 37, "!!", 69);
 
7
    if (nv == null) {
 
8
      Test.fail ();
 
9
      Test.message ("`new NamedVector ()` returned a null.");
 
10
    }
 
11
  });
 
12
 
 
13
  Test.add_func (VEE_TEST_NAMED_VECTOR_PREFIX + "sanity", () => {
 
14
    var nv = new NamedVector<int> ("A", 1, "B", 2, "C", 3);
 
15
    
 
16
    var tmp_name = nv.names[0];
 
17
    if (tmp_name != "A") {
 
18
      Test.message ("Gotten value (%s) did not match the" +
 
19
                      " expected value (A)", nv.names[0]);
 
20
    }
 
21
 
 
22
    tmp_name = nv.names[1];
 
23
    if (tmp_name != "B") {
 
24
      Test.message ("Gotten value (%s) did not match the" +
 
25
                      " expected value (B)", nv.names[0]);
 
26
    }
 
27
 
 
28
    tmp_name = nv.names[2];
 
29
    if (tmp_name != "C") {
 
30
      Test.message ("Gotten value (%s) did not match the" +
 
31
                      " expected value (C)", nv.names[0]);
 
32
    }
 
33
 
 
34
  });
 
35
 
 
36
  Test.add_func (VEE_TEST_NAMED_VECTOR_PREFIX + "foreach", () => {
 
37
    var nv = new NamedVector<int> ("A", 1, "B", 2, "C", 3);
 
38
 
 
39
    nv.foreach ((name, val) => {
 
40
      message ("%s has the value: %i \n", name, val);
 
41
      return true;
 
42
    });
 
43
  });
 
44
}