1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 Copyright (c) 2012 The Chromium Authors. All rights reserved. 5 Use of this source code is governed by a BSD-style license that can be 6 found in the LICENSE file. 7 --> 8 <head> 9 <title>Range tests</title> 10 <script src="base.js"></script> 11 <script> 12 base.require('unittest'); 13 base.require('test_utils'); 14 base.require('range'); 15 </script> 16 </head> 17 <body> 18 <script> 19 'use strict'; 20 21 var Range = base.Range; 22 23 function testAddValue() { 24 var range = new Range(); 25 assertTrue(range.isEmpty); 26 range.addValue(1); 27 assertFalse(range.isEmpty); 28 assertEquals(range.min, 1); 29 assertEquals(range.max, 1); 30 31 range.addValue(2); 32 assertFalse(range.isEmpty); 33 assertEquals(range.min, 1); 34 assertEquals(range.max, 2); 35 } 36 37 function testAddNonEmptyRange1() { 38 var r1 = new Range(); 39 r1.addValue(1); 40 r1.addValue(2); 41 42 var r = new Range(); 43 r.addRange(r1); 44 assertEquals(r.min, 1); 45 assertEquals(r.max, 2); 46 } 47 48 function testAddEmptyRange() { 49 var r1 = new Range(); 50 51 var r = new Range(); 52 r.addRange(r1); 53 assertTrue(r.isEmpty); 54 assertEquals(r.min, undefined); 55 assertEquals(r.max, undefined); 56 } 57 58 function testAddEmptyRange() { 59 var r1 = new Range(); 60 r1.addValue(1); 61 r1.addValue(2); 62 63 var r = new Range(); 64 r.addValue(3); 65 r.addRange(r1); 66 assertFalse(r.isEmpty); 67 assertEquals(r.min, 1); 68 assertEquals(r.max, 3); 69 } 70 71 </script> 72 </body> 73 </html> 74