This repository was archived by the owner on Dec 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 9 files changed +23
-23
lines changed
javatests/com/google/census Expand file tree Collapse file tree 9 files changed +23
-23
lines changed Original file line number Diff line number Diff line change @@ -162,8 +162,8 @@ java_test(
162162)
163163
164164java_test (
165- name = "StringSanitizationTest " ,
166- srcs = ["core/javatests/com/google/census/StringSanitizationTest .java" ],
165+ name = "StringUtilTest " ,
166+ srcs = ["core/javatests/com/google/census/StringUtilTest .java" ],
167167 deps = [
168168 ":census-core" ,
169169 ":census-core_native" ,
Original file line number Diff line number Diff line change 1919 * MetricName's are {@link String}s with enforced restrictions.
2020 */
2121public final class MetricName {
22- public static final int MAX_LENGTH = StringSanitization .MAX_LENGTH ;
22+ public static final int MAX_LENGTH = StringUtil .MAX_LENGTH ;
2323
2424 public MetricName (String name ) {
25- this .name = StringSanitization .sanitize (name );
25+ this .name = StringUtil .sanitize (name );
2626 }
2727
2828 @ Override
Original file line number Diff line number Diff line change 1414package com .google .census ;
1515
1616/**
17- * Utility methods for sanitizing tag keys, tag values, and metric names.
17+ * Utility methods for working with tag keys, tag values, and metric names.
1818 */
19- final class StringSanitization {
19+ final class StringUtil {
2020
2121 static final int MAX_LENGTH = 255 ;
2222 static final char UNPRINTABLE_CHAR_SUBSTITUTE = '_' ;
@@ -50,7 +50,7 @@ private static boolean isPrintableChar(char c) {
5050 }
5151
5252 //Visible for testing
53- StringSanitization () {
53+ StringUtil () {
5454 throw new AssertionError ();
5555 }
5656}
Original file line number Diff line number Diff line change 1919 * TagKey's are {@link String}s with enforced restrictions.
2020 */
2121public final class TagKey {
22- public static final int MAX_LENGTH = StringSanitization .MAX_LENGTH ;
22+ public static final int MAX_LENGTH = StringUtil .MAX_LENGTH ;
2323
2424 public TagKey (String key ) {
25- this .key = StringSanitization .sanitize (key );
25+ this .key = StringUtil .sanitize (key );
2626 }
2727
2828 @ Override
Original file line number Diff line number Diff line change 1919 * TagValue's are {@link String}s with enforced restrictions.
2020 */
2121public final class TagValue {
22- public static final int MAX_LENGTH = StringSanitization .MAX_LENGTH ;
22+ public static final int MAX_LENGTH = StringUtil .MAX_LENGTH ;
2323
2424 public TagValue (String value ) {
25- this .value = StringSanitization .sanitize (value );
25+ this .value = StringUtil .sanitize (value );
2626 }
2727
2828 @ Override
Original file line number Diff line number Diff line change @@ -39,8 +39,8 @@ public void testNameMaxLength() {
3939 @ Test
4040 public void testNameBadChar () {
4141 assertThat (new MetricName ("\2 ab\3 cd" ).toString ())
42- .isEqualTo (StringSanitization .UNPRINTABLE_CHAR_SUBSTITUTE + "ab"
43- + StringSanitization .UNPRINTABLE_CHAR_SUBSTITUTE + "cd" );
42+ .isEqualTo (StringUtil .UNPRINTABLE_CHAR_SUBSTITUTE + "ab"
43+ + StringUtil .UNPRINTABLE_CHAR_SUBSTITUTE + "cd" );
4444 }
4545
4646 @ Test
Original file line number Diff line number Diff line change 2424 * Tests for {@link StringUtil}.
2525 */
2626@ RunWith (JUnit4 .class )
27- public final class StringSanitizationTest {
27+ public final class StringUtilTest {
2828 @ Test
2929 public void testMaxLength () {
30- char [] string = new char [StringSanitization .MAX_LENGTH ];
31- char [] truncString = new char [StringSanitization .MAX_LENGTH + 10 ];
30+ char [] string = new char [StringUtil .MAX_LENGTH ];
31+ char [] truncString = new char [StringUtil .MAX_LENGTH + 10 ];
3232 Arrays .fill (string , 'v' );
3333 Arrays .fill (truncString , 'v' );
34- assertThat (StringSanitization .sanitize (new String (truncString ))).isEqualTo (new String (string ));
34+ assertThat (StringUtil .sanitize (new String (truncString ))).isEqualTo (new String (string ));
3535 }
3636
3737 @ Test
3838 public void testBadChar () {
3939 String string = "\2 ab\3 cd" ;
40- assertThat (StringSanitization .sanitize (string ).toString ()).isEqualTo ("_ab_cd" );
40+ assertThat (StringUtil .sanitize (string ).toString ()).isEqualTo ("_ab_cd" );
4141 }
4242
4343 @ Test (expected =AssertionError .class )
4444 public void testConstructor () {
45- new StringSanitization ();
45+ new StringUtil ();
4646 }
4747}
Original file line number Diff line number Diff line change @@ -41,8 +41,8 @@ public void testKeyMaxLength() {
4141 public void testKeyBadChar () {
4242 String key = "\2 ab\3 cd" ;
4343 assertThat (new TagKey (key ).toString ())
44- .isEqualTo (StringSanitization .UNPRINTABLE_CHAR_SUBSTITUTE + "ab"
45- + StringSanitization .UNPRINTABLE_CHAR_SUBSTITUTE + "cd" );
44+ .isEqualTo (StringUtil .UNPRINTABLE_CHAR_SUBSTITUTE + "ab"
45+ + StringUtil .UNPRINTABLE_CHAR_SUBSTITUTE + "cd" );
4646 }
4747
4848 @ Test
Original file line number Diff line number Diff line change @@ -40,8 +40,8 @@ public void testValueMaxLength() {
4040 public void testValueBadChar () {
4141 String value = "\2 ab\3 cd" ;
4242 assertThat (new TagValue (value ).toString ())
43- .isEqualTo (StringSanitization .UNPRINTABLE_CHAR_SUBSTITUTE + "ab"
44- + StringSanitization .UNPRINTABLE_CHAR_SUBSTITUTE + "cd" );
43+ .isEqualTo (StringUtil .UNPRINTABLE_CHAR_SUBSTITUTE + "ab"
44+ + StringUtil .UNPRINTABLE_CHAR_SUBSTITUTE + "cd" );
4545 }
4646
4747 @ Test
You can’t perform that action at this time.
0 commit comments