Make group order test work with oracle sort order

This commit is contained in:
hns 2009-09-15 14:54:36 +00:00
parent 684346bb49
commit b0c72c989e

View file

@ -12,7 +12,7 @@ function setup() {
for (var i = 0; i < size; i++) { for (var i = 0; i < size; i++) {
var org = new Organisation(); var org = new Organisation();
org.name = "Organisation " + i; org.name = "Organisation " + i;
org.country = "C" + i; org.country = "CH" + i.format("0000");
root.organisations.add(org); root.organisations.add(org);
} }
res.commit(); res.commit();
@ -71,17 +71,17 @@ function testGroupByAddRemoveNoCommit() {
function testGroupOrder() { function testGroupOrder() {
var org1 = new Organisation(); var org1 = new Organisation();
org1.country = "AT" + Math.random(); org1.country = "AT";
org1.name = "Helma" + Math.random(); org1.name = "Helma" + Math.random();
root.organisations.add(org1); root.organisations.add(org1);
var org2 = new Organisation(); var org2 = new Organisation();
org2.country = "CH" + Math.random(); org2.country = "CH01"; // pre-populated items have countries CH0000..C1234
org2.name = "Helma" + Math.random(); org2.name = "Helma" + Math.random();
root.organisations.add(org2); root.organisations.add(org2);
var org3 = new Organisation(); var org3 = new Organisation();
org3.country = "DE" + Math.random(); org3.country = "DE";
org3.name = "Helma" + Math.random(); org3.name = "Helma" + Math.random();
root.organisations.add(org3); root.organisations.add(org3);
@ -94,10 +94,15 @@ function testGroupOrder() {
// make sure that countries and organisations are sorted in decreasing order (as specified in type.properties) // make sure that countries and organisations are sorted in decreasing order (as specified in type.properties)
var countries = root.organisationsByCountry.list(); var countries = root.organisationsByCountry.list();
for (var i=0; i<root.organisationsByCountry.count(); i++) { assertEqual(countries.length, size + 3);
if (i>0) assertTrue(root.organisationsByCountry.get(i-1)._id >= root.organisationsByCountry.get(i)._id) for (var i = 0; i < countries.length; i++) {
for (var j=0; j<root.organisationsByCountry.get(i); j++) { if (i>0) {
if (j>0) assertTrue(root.organisationsByCountry.get(i).get(j-1)._id >= root.organisationsByCountry.get(i).get(j)._id) assertTrue(root.organisationsByCountry.get(i-1).groupname >= root.organisationsByCountry.get(i).groupname);
}
for (var j = 0; j < root.organisationsByCountry.get(i); j++) {
if (j > 0) {
assertTrue(root.organisationsByCountry.get(i).get(j-1).groupname >= root.organisationsByCountry.get(i).get(j).groupname);
}
} }
} }