blob: f81960d5969e2d9ab56ec35ac508f42f850be236 [file] [log] [blame]
// 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.
/**
* Test fixture for the MeasurementSystem.
* @constructor
* @extends {testing.Test}
*/
function MeasurementSystemUnitTest() {
testing.Test.call(this);
}
MeasurementSystemUnitTest.prototype = {
__proto__: testing.Test.prototype,
extraLibraries: [
'../../../../../ui/webui/resources/js/cr.js',
'../print_preview_utils.js',
'measurement_system.js'
]
};
TEST_F('MeasurementSystemUnitTest', 'parseNumberFormat', function() {
assertTrue(areArraysEqual(
['.', ','],
print_preview.MeasurementSystem.parseNumberFormat('123.456,78')));
assertTrue(areArraysEqual(
['.', '.'],
print_preview.MeasurementSystem.parseNumberFormat('123.456.78')));
assertTrue(areArraysEqual(
[',', '.'],
print_preview.MeasurementSystem.parseNumberFormat('123,456.78')));
assertTrue(areArraysEqual(
[',', ','],
print_preview.MeasurementSystem.parseNumberFormat('123,456,78')));
assertTrue(areArraysEqual(
[' ', ','],
print_preview.MeasurementSystem.parseNumberFormat('123 456,78')));
assertTrue(areArraysEqual(
[' ', '.'],
print_preview.MeasurementSystem.parseNumberFormat('123 456.78')));
assertTrue(areArraysEqual(
[' ', ' '],
print_preview.MeasurementSystem.parseNumberFormat('123 456 78')));
assertTrue(areArraysEqual(
['', ''],
print_preview.MeasurementSystem.parseNumberFormat('123')));
assertTrue(areArraysEqual(
[',', '.'],
print_preview.MeasurementSystem.parseNumberFormat('abcdef')));
assertTrue(areArraysEqual(
[',', '.'],
print_preview.MeasurementSystem.parseNumberFormat(null)));
assertTrue(areArraysEqual(
[',', '.'],
print_preview.MeasurementSystem.parseNumberFormat(undefined)));
assertTrue(areArraysEqual(
[',', '.'],
print_preview.MeasurementSystem.parseNumberFormat('')));
assertTrue(areArraysEqual(
[',', '.'],
print_preview.MeasurementSystem.parseNumberFormat('1')));
assertTrue(areArraysEqual(
[',', '.'],
print_preview.MeasurementSystem.parseNumberFormat('12')));
});