blob: 68ac2adf2e0a2d6f27635ad3955924df3ddfe7d4 [file] [log] [blame]
Simon Huntbe60dde2016-01-13 12:26:56 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Simon Huntbe60dde2016-01-13 12:26:56 -08003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.ui.table.cell;
18
19import org.junit.Test;
20import org.onosproject.ui.table.CellFormatter;
21
22import static org.junit.Assert.assertEquals;
23
24/**
25 * Unit tests for {@link NumberFormatter}.
26 */
27public class NumberFormatterTest {
28
29
30 private CellFormatter f5dp = NumberFormatter.TO_5DP;
31 private CellFormatter fInt = NumberFormatter.INTEGER;
32
33 @Test
34 public void defaultNullValue() {
35 assertEquals("default null value", "", f5dp.format(null));
36 }
37
38 @Test
39 public void defaultZero() {
40 assertEquals("default zero", "0.00000", f5dp.format(0));
41 }
42
43 @Test
44 public void defaultFifty() {
45 assertEquals("default fifty", "50.00000", f5dp.format(50));
46 }
47
48 @Test
49 public void default2G() {
50 assertEquals("default 2G", "2,000.00000", f5dp.format(2000));
51 }
52
53 @Test
54 public void integerNullValue() {
55 assertEquals("integer null value", "", fInt.format(null));
56 }
57
58 @Test
59 public void integerZero() {
60 assertEquals("integer zero", "0", fInt.format(0));
61 }
62
63 @Test
64 public void integerFifty() {
65 assertEquals("integer fifty", "50", fInt.format(50));
66 }
67
68 @Test
69 public void integer2G() {
70 assertEquals("integer 2G", "2,000", fInt.format(2000));
71 }
72
73 @Test
74 public void integer5M() {
75 assertEquals("integer 5M", "5,000,042", fInt.format(5000042));
76 }
77
78}