Home | History | Annotate | Download | only in base
      1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 'use strict';
      6 
      7 base.require('base.range');
      8 
      9 base.unittest.testSuite('base.range', function() {
     10   test('addValue', function() {
     11     var range = new base.Range();
     12     assertTrue(range.isEmpty);
     13     range.addValue(1);
     14     assertFalse(range.isEmpty);
     15     assertEquals(range.min, 1);
     16     assertEquals(range.max, 1);
     17 
     18     range.addValue(2);
     19     assertFalse(range.isEmpty);
     20     assertEquals(range.min, 1);
     21     assertEquals(range.max, 2);
     22   });
     23 
     24   test('addNonEmptyRange', function() {
     25     var r1 = new base.Range();
     26     r1.addValue(1);
     27     r1.addValue(2);
     28 
     29     var r = new base.Range();
     30     r.addRange(r1);
     31     assertEquals(r.min, 1);
     32     assertEquals(r.max, 2);
     33   });
     34 
     35   test('addEmptyRange', function() {
     36     var r1 = new base.Range();
     37 
     38     var r = new base.Range();
     39     r.addRange(r1);
     40     assertTrue(r.isEmpty);
     41     assertEquals(r.min, undefined);
     42     assertEquals(r.max, undefined);
     43   });
     44 
     45   test('addRangeToRange', function() {
     46     var r1 = new base.Range();
     47     r1.addValue(1);
     48     r1.addValue(2);
     49 
     50     var r = new base.Range();
     51     r.addValue(3);
     52     r.addRange(r1);
     53 
     54     assertFalse(r.isEmpty);
     55     assertEquals(r.min, 1);
     56     assertEquals(r.max, 3);
     57   });
     58 });
     59