blob: dce969d7583cfef1c19296c77ed679cff49a62ef [file] [log] [blame]
<!DOCTYPE html>
<!--
Copyright (c) 2014 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<link rel="import" href="/base/iteration_helpers.html">
<script>
'use strict';
tv.b.unittest.testSuite(function() {
var comparePossiblyUndefinedValues = tv.b.comparePossiblyUndefinedValues;
var compareArrays = tv.b.compareArrays;
test('comparePossiblyUndefinedValues', function() {
function cmp(x, y) {
assert.isDefined(x);
assert.isDefined(y);
return x - y;
}
assert.isBelow(comparePossiblyUndefinedValues(0, 1, cmp), 0);
assert.isAbove(comparePossiblyUndefinedValues(1, 0, cmp), 0);
assert.equal(comparePossiblyUndefinedValues(1, 1, cmp), 0);
assert.isBelow(comparePossiblyUndefinedValues(0, undefined, cmp), 0);
assert.isAbove(comparePossiblyUndefinedValues(undefined, 0, cmp), 0);
assert.equal(comparePossiblyUndefinedValues(undefined, undefined, cmp), 0);
});
test('compareArrays', function() {
function cmp(x, y) {
assert.isDefined(x);
assert.isDefined(y);
return x - y;
}
assert.isBelow(compareArrays([1], [2], cmp), 0);
assert.isAbove(compareArrays([2], [1], cmp), 0);
assert.isBelow(compareArrays([1], [1, 2], cmp), 0);
assert.isAbove(compareArrays([1, 2], [1], cmp), 0);
assert.isBelow(compareArrays([], [1], cmp), 0);
assert.isAbove(compareArrays([1], [], cmp), 0);
assert.isAbove(compareArrays([2], [1], cmp), 0);
assert.equal(compareArrays([], [], cmp), 0);
assert.equal(compareArrays([1], [1], cmp), 0);
});
});
</script>