vala-tests r18 - trunk/tests/bugs
- From: sebp svn gnome org
- To: svn-commits-list gnome org
- Subject: vala-tests r18 - trunk/tests/bugs
- Date: Sat, 18 Oct 2008 11:00:32 +0000 (UTC)
Author: sebp
Date: Sat Oct 18 11:00:32 2008
New Revision: 18
URL: http://svn.gnome.org/viewvc/vala-tests?rev=18&view=rev
Log:
Added test case for bug 539969
Added:
trunk/tests/bugs/539969.test (contents, props changed)
trunk/tests/bugs/539969.vala
Added: trunk/tests/bugs/539969.test
==============================================================================
--- (empty file)
+++ trunk/tests/bugs/539969.test Sat Oct 18 11:00:32 2008
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+set -e
+
+SRCDIR=../tests/bugs
+
+if [ "x$VALAC" = "x" ] ; then
+ VALAC=valac
+ SRCDIR=.
+fi
+
+TESTNAME=`basename $0 .test`
+
+$VALAC --pkg gee-1.0 -o $TESTNAME $SRCDIR/$TESTNAME.vala $VALAFLAGS
+
+G_DEBUG=fatal_warnings ./$TESTNAME $@
+
Added: trunk/tests/bugs/539969.vala
==============================================================================
--- (empty file)
+++ trunk/tests/bugs/539969.vala Sat Oct 18 11:00:32 2008
@@ -0,0 +1,65 @@
+using GLib;
+using Gee;
+
+public class Number : GLib.Object {
+
+ public int Value {get; set;}
+
+ public Number (int val) {
+ this.Value = val;
+ }
+
+ public static int compare (Number* n1, Number* n2) {
+ if (n1->Value > n2->Value) return -1;
+ else if (n1->Value < n2->Value) return 1;
+ else return 0;
+ }
+}
+
+public class Test : GLib.Object {
+
+ public HashMap<int, SequenceIter<Number>> event_id_map;
+ public Sequence<Number> numbers;
+
+ construct {
+ this.event_id_map = new HashMap<int, SequenceIter<Number>> ();
+ this.numbers = new Sequence<Number> (null);
+ }
+
+ public void add (Number# n) {
+ SequenceIter<Number> iter = this.numbers.insert_sorted (n, Number.compare);
+ this.event_id_map.set (n.Value, iter);
+
+ assert (this.event_id_map.size == this.numbers.get_length ());
+ }
+
+ public static void main (string[] args) {
+ Test t = new Test ();
+
+ Number[] numbers = new Number[7];
+ numbers[0] = new Number (-1);
+ numbers[1] = new Number (1);
+ numbers[2] = new Number (3);
+ numbers[3] = new Number (5);
+ numbers[4] = new Number (-1274);
+ numbers[5] = new Number (128359);
+ numbers[6] = new Number (0);
+
+ t.add (#numbers[0]);
+ t.add (#numbers[1]);
+ t.add (#numbers[2]);
+ t.add (#numbers[3]);
+ t.add (#numbers[4]);
+ t.add (#numbers[5]);
+ t.add (#numbers[6]);
+
+ assert (t.event_id_map.size == 7);
+ assert (t.numbers.get_length () == 7);
+ foreach (int i in t.event_id_map.get_keys ()) {
+ SequenceIter<Number> iter = t.event_id_map.get (i);
+ Number n = t.numbers.get (iter);
+ assert (n.Value == i);
+ }
+ }
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]