Project

General

Profile

Revision 48cdd986

ID48cdd986b3b723299a4355d9ca66b1efe79699a2
Parent 3bc664c1
Child 3ca67b85

Added by Andreas Kohlbecker about 2 years ago

CoordinateConverterTest using unicode constants for all signs

View differences:

cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/parser/location/CoordinateConverterTest.java
26 26

  
27 27
	private CoordinateConverter coordinateConverter;
28 28

  
29
	// Unicode constants
30
	private static final char DEGREE_SIGN = '\u00B0';
31
	private static final char MASCULINE_ORDINAL_INDICATOR = '\u00BA';
32

  
33
	private static final char APOSTROPHE = 0x0027;
34
	private static final char QUOTATION_MARK = '\u0022';
35
	private static final char ACUTE_ACCENT = '\u00B4';
36
	private static final char RIGHT_SINGLE_QUOTATION_MARK = '\u2019';
37
	private static final char RIGHT_DOUBLE_QUOTATION_MARK = '\u201D';
38

  
29 39
	/**
30 40
	 * @throws java.lang.Exception
31 41
	 */
......
56 66
	 */
57 67
	@Test
58 68
	public void testTryConvert() {
59
		ConversionResults conversionResults = coordinateConverter.tryConvert("35\u00B034'20\"S");
69
		ConversionResults conversionResults = coordinateConverter.tryConvert("35" + DEGREE_SIGN + "34" + APOSTROPHE + "20" + QUOTATION_MARK + "S");
60 70
		Assert.assertTrue(conversionResults.conversionComments, conversionResults.patternRecognised);
61 71
		Assert.assertTrue("Southern must be negative", conversionResults.convertedCoord < 0);
62 72
		Assert.assertFalse("Southern must be latitude", conversionResults.isLongitude);
63 73

  
64
		conversionResults = coordinateConverter.tryConvert("35\u00BA34.744");
74
		conversionResults = coordinateConverter.tryConvert("35" + MASCULINE_ORDINAL_INDICATOR + "34.744");
65 75
		Assert.assertTrue(conversionResults.conversionComments, conversionResults.patternRecognised);
66 76
		Assert.assertNull("Longitude must be undefined", conversionResults.isLongitude);
67 77

  
68
		conversionResults = coordinateConverter.tryConvert("95\u00B034.744");
78
		conversionResults = coordinateConverter.tryConvert("95" + DEGREE_SIGN + "34.744");
69 79
		Assert.assertTrue("Longitude must be defined", conversionResults.isLongitude);
70 80

  
71 81

  
72
		conversionResults = coordinateConverter.tryConvert("-35\u00B034'55.67S");
82
		conversionResults = coordinateConverter.tryConvert("-35" + DEGREE_SIGN + "34" + APOSTROPHE + "55.67S");
73 83
		Assert.assertTrue(conversionResults.conversionComments, conversionResults.patternRecognised);
74 84

  
75
		conversionResults = coordinateConverter.tryConvert("35\u00B011'34.744SN");
85
		conversionResults = coordinateConverter.tryConvert("35" + DEGREE_SIGN + "11" + APOSTROPHE + "34.744SN");
76 86
		Assert.assertTrue(conversionResults.conversionComments, conversionResults.patternRecognised);
77 87

  
78
		conversionResults = coordinateConverter.tryConvert("35\u00B011'34.744SW");
88
		conversionResults = coordinateConverter.tryConvert("35" + DEGREE_SIGN + "11" + APOSTROPHE + "34.744SW");
79 89
		Assert.assertTrue("Western must be longitude", conversionResults.isLongitude);
80 90

  
81
		conversionResults = coordinateConverter.tryConvert("35\u00B0 1'34.744SW");
91
		conversionResults = coordinateConverter.tryConvert("35" + DEGREE_SIGN + " 1" + APOSTROPHE + "34.744SW");
82 92
		Assert.assertTrue("Pattern with whitespace must be recognised", conversionResults.patternRecognised);
83 93
		Assert.assertTrue("Pattern with whitespace must be recognised", conversionResults.conversionSuccessful);
84 94

  
85 95
		conversionResults = coordinateConverter.tryConvert("35D11M34.744S");
86 96
		Assert.assertNull("isLongitude must be undefined. S stands for second.", conversionResults.isLongitude);
87 97

  
88
        conversionResults = coordinateConverter.tryConvert("35\u00B0 1\u00B434.744SW");
98
        conversionResults = coordinateConverter.tryConvert("35" + DEGREE_SIGN + " 1" + ACUTE_ACCENT + "34.744SW");
89 99
        Assert.assertTrue("Pattern with acute accent must be recognised", conversionResults.patternRecognised);
90 100
        Assert.assertTrue("Pattern with acute accent must be recognised", conversionResults.conversionSuccessful);
91 101

  
92
        conversionResults = coordinateConverter.tryConvert("35\u00B01\u00B434\u00B4\u00B4W");
102
        conversionResults = coordinateConverter.tryConvert("35" + DEGREE_SIGN + "1" + ACUTE_ACCENT + "34" + ACUTE_ACCENT + "" + ACUTE_ACCENT + "W");
93 103
        Assert.assertTrue("Pattern with acute accent for seconds must be recognised", conversionResults.patternRecognised);
94 104
        Assert.assertTrue("Pattern with acute accent for seconds  must be recognised", conversionResults.conversionSuccessful);
95 105

  
......
102 112

  
103 113
	    //4º 58’ N, 118º 10’ E
104 114
	    //minutes
105
	    ConversionResults conversionResults = coordinateConverter.tryConvert("4\u00B058\u2019N");
115
	    ConversionResults conversionResults = coordinateConverter.tryConvert("4" + DEGREE_SIGN + "58" + RIGHT_SINGLE_QUOTATION_MARK + "N");
106 116
	    Assert.assertTrue(conversionResults.conversionComments, conversionResults.patternRecognised);
107 117
	    Assert.assertTrue("Pattern with english quotation end for minute must be recognised", conversionResults.patternRecognised);
108 118
        Assert.assertTrue("Pattern with english quotation end for minute  must be successful", conversionResults.conversionSuccessful);
109 119

  
110
        conversionResults = coordinateConverter.tryConvert("4\u00B058\u2019 N");
120
        conversionResults = coordinateConverter.tryConvert("4" + DEGREE_SIGN + "58" + RIGHT_SINGLE_QUOTATION_MARK + " N");
111 121
        Assert.assertTrue(conversionResults.conversionComments, conversionResults.patternRecognised);
112 122
        Assert.assertTrue("Pattern with english quotation and whitespace must be recognised", conversionResults.patternRecognised);
113 123
        Assert.assertTrue("Pattern with english quotation and whitespace must be successful", conversionResults.conversionSuccessful);
114 124

  
115
        conversionResults = coordinateConverter.tryConvert("4\u00B0 58\u201944\" N");
125
        conversionResults = coordinateConverter.tryConvert("4" + DEGREE_SIGN + " 58" + RIGHT_SINGLE_QUOTATION_MARK + "44\" N");
116 126
        Assert.assertTrue(conversionResults.conversionComments, conversionResults.patternRecognised);
117 127
        Assert.assertTrue("Pattern with english quotation and whitespace must be recognised", conversionResults.patternRecognised);
118 128
        Assert.assertTrue("Pattern with english quotation and whitespace must be successful", conversionResults.conversionSuccessful);
119 129

  
120
        conversionResults = coordinateConverter.tryConvert("118\u00B0 10\u201933\" E");
130
        conversionResults = coordinateConverter.tryConvert("118" + DEGREE_SIGN + " 10" + RIGHT_SINGLE_QUOTATION_MARK + "33\" E");
121 131
        Assert.assertTrue(conversionResults.conversionComments, conversionResults.patternRecognised);
122 132
        Assert.assertTrue("Pattern with english quotation and whitespace must be recognised", conversionResults.patternRecognised);
123 133
        Assert.assertTrue("Pattern with english quotation and whitespace must be successful", conversionResults.conversionSuccessful);
124 134

  
125 135
        //seconds
126
        conversionResults = coordinateConverter.tryConvert("4\u00B058\u201944\u201DN");
136
        conversionResults = coordinateConverter.tryConvert("4" + DEGREE_SIGN + "58" + RIGHT_SINGLE_QUOTATION_MARK + "44" + RIGHT_DOUBLE_QUOTATION_MARK + "N");
127 137
        Assert.assertTrue(conversionResults.conversionComments, conversionResults.patternRecognised);
128 138
        Assert.assertTrue("Pattern with right double quotation for second must be recognised", conversionResults.patternRecognised);
129 139
        Assert.assertTrue("Pattern with right double quotation for second must be successful", conversionResults.conversionSuccessful);
130 140

  
131
        conversionResults = coordinateConverter.tryConvert("4\u00B058\u201944\u201D N");
141
        conversionResults = coordinateConverter.tryConvert("4" + DEGREE_SIGN + "58" + RIGHT_SINGLE_QUOTATION_MARK + "44" + RIGHT_DOUBLE_QUOTATION_MARK + " N");
132 142
        Assert.assertTrue(conversionResults.conversionComments, conversionResults.patternRecognised);
133 143
        Assert.assertTrue("Pattern with right double quotation and whitespace must be recognised", conversionResults.patternRecognised);
134 144
        Assert.assertTrue("Pattern with right double quotation and whitespace must be successful", conversionResults.conversionSuccessful);
135 145

  
136
        conversionResults = coordinateConverter.tryConvert("118\u00B0 10\u201933\u201D E");
146
        conversionResults = coordinateConverter.tryConvert("118" + DEGREE_SIGN + " 10" + RIGHT_SINGLE_QUOTATION_MARK + "33" + RIGHT_DOUBLE_QUOTATION_MARK + " E");
137 147
        Assert.assertTrue(conversionResults.conversionComments, conversionResults.patternRecognised);
138 148
        Assert.assertTrue("Pattern with right double quotation and whitespace must be recognised", conversionResults.patternRecognised);
139 149
        Assert.assertTrue("Pattern with right double quotation and whitespace must be successful", conversionResults.conversionSuccessful);

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)