<!DOCTYPE HTML> <html> <!-- Copyright (c) 2012 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. --> <head> <title>Range tests</title> <script src="base.js"></script> <script> base.require('unittest'); base.require('test_utils'); base.require('range'); </script> </head> <body> <script> 'use strict'; var Range = base.Range; function testAddValue() { var range = new Range(); assertTrue(range.isEmpty); range.addValue(1); assertFalse(range.isEmpty); assertEquals(range.min, 1); assertEquals(range.max, 1); range.addValue(2); assertFalse(range.isEmpty); assertEquals(range.min, 1); assertEquals(range.max, 2); } function testAddNonEmptyRange1() { var r1 = new Range(); r1.addValue(1); r1.addValue(2); var r = new Range(); r.addRange(r1); assertEquals(r.min, 1); assertEquals(r.max, 2); } function testAddEmptyRange() { var r1 = new Range(); var r = new Range(); r.addRange(r1); assertTrue(r.isEmpty); assertEquals(r.min, undefined); assertEquals(r.max, undefined); } function testAddEmptyRange() { var r1 = new Range(); r1.addValue(1); r1.addValue(2); var r = new Range(); r.addValue(3); r.addRange(r1); assertFalse(r.isEmpty); assertEquals(r.min, 1); assertEquals(r.max, 3); } </script> </body> </html>