1 package org.pojomatic.formatter;
2
3 import org.testng.annotations.Test;
4 import org.testng.annotations.BeforeMethod;
5 import static org.testng.Assert.*;
6
7 import java.util.Arrays;
8
9 @Deprecated
10 public class DefaultPropertyFormatterTest {
11 private PropertyFormatter formatter;
12
13 @BeforeMethod
14 public void setUp() {
15 formatter = new DefaultPropertyFormatter();
16 formatter.initialize(null);
17 }
18
19 @Test public void testFormat() {
20 assertEquals(formatter.format(7), "7");
21 }
22
23 @Test public void testFormatNull() {
24 assertEquals(formatter.format(null), "null");
25 }
26
27 @Test public void testFormatList() {
28 assertEquals(formatter.format(Arrays.asList(5, 7)), "[5, 7]");
29 }
30
31 @Test public void testFormatArrayOfObjects() {
32 assertEquals(formatter.format(new Integer[] {5, 7}), "[5, 7]");
33 }
34
35 @Test public void testFormatArrayOfBooleans() {
36 assertEquals(formatter.format(new boolean[] {true, false}), "[true, false]");
37 }
38
39 @Test public void testFormatArrayOfBytes() {
40 assertEquals(formatter.format(new byte[] {5, 7}), "[5, 7]");
41 }
42
43 @Test public void testFormatArrayOfChars() {
44 assertEquals(formatter.format(new char[] {5, 'b'}), "['0x5', 'b']");
45 }
46
47 @Test public void testFormatArrayOfShorts() {
48 assertEquals(formatter.format(new short[] {5, 7}), "[5, 7]");
49 }
50
51 @Test public void testFormatArrayOfInts() {
52 assertEquals(formatter.format(new int[] {5, 7}), "[5, 7]");
53 }
54
55 @Test public void testFormatArrayOfLongs() {
56 assertEquals(formatter.format(new long[] {5, 7}), "[5, 7]");
57 }
58
59 @Test public void testFormatArrayOfFloats() {
60 assertEquals(formatter.format(new float[] {5, 7}), "[5.0, 7.0]");
61 }
62
63 @Test public void testFormatArrayOfDoubles() {
64 assertEquals(formatter.format(new double[] {5, 7}), "[5.0, 7.0]");
65 }
66
67 @Test public void testFormatDoubleArray() {
68 assertEquals(formatter.format(new Integer[][] {new Integer[] { 1, 2 }, new Integer[] {3, 4} }), "[[1, 2], [3, 4]]");
69 }
70
71 @Test public void testFormatDoubleArrayOfPrimitives() {
72 assertEquals(formatter.format(new int[][] {new int[] { 1, 2 }, new int[] {3, 4} }), "[[1, 2], [3, 4]]");
73 }
74 }