1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 package org.apache.hc.core5.util;
29
30 import org.junit.Assert;
31 import org.junit.Test;
32
33
34
35
36
37 public class TestTextUtils {
38
39 @Test
40 public void testTextEmpty() {
41 Assert.assertTrue(TextUtils.isEmpty(null));
42 Assert.assertTrue(TextUtils.isEmpty(""));
43 Assert.assertFalse(TextUtils.isEmpty("\t"));
44 }
45
46 @Test
47 public void testTextBlank() {
48 Assert.assertTrue(TextUtils.isBlank(null));
49 Assert.assertTrue(TextUtils.isBlank(""));
50 Assert.assertTrue(TextUtils.isBlank(" "));
51 Assert.assertTrue(TextUtils.isBlank("\t"));
52 }
53
54 @Test
55 public void testTextContainsBlanks() {
56 Assert.assertFalse(TextUtils.containsBlanks(null));
57 Assert.assertFalse(TextUtils.containsBlanks(""));
58 Assert.assertTrue(TextUtils.containsBlanks(" "));
59 Assert.assertTrue(TextUtils.containsBlanks("\t"));
60 Assert.assertTrue(TextUtils.containsBlanks(" a"));
61 Assert.assertFalse(TextUtils.containsBlanks("a"));
62 }
63
64 @Test
65 public void testToHexString() {
66 Assert.assertEquals("000c2001", TextUtils.toHexString(new byte[] { 0, 12, 32, 1 }));
67 Assert.assertEquals(null, TextUtils.toHexString(null));
68 }
69
70 }