aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test
diff options
context:
space:
mode:
authorGravatar michajlo <michajlo@google.com>2017-10-17 23:07:09 +0200
committerGravatar Jakob Buchgraber <buchgr@google.com>2017-10-18 10:28:25 +0200
commit1606cf208cc5194b13ca212819371f7e4ba43a6b (patch)
tree62cc37550ee4db1983d42edf6101c260c92aac8b /src/test
parentba2a65098c8b1d1e0b2f75bfbcc41469fcb001fa (diff)
Fall back on basic StringCodec if FastStringCodec isn't available
Also adds a method which can be used to tell if this behavior actually applied, for more performance-sensitive users. PiperOrigin-RevId: 172512011
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/serialization/strings/FastStringCodecTest.java3
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/serialization/strings/StringCodecsTest.java36
2 files changed, 38 insertions, 1 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/serialization/strings/FastStringCodecTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/serialization/strings/FastStringCodecTest.java
index b472f54b49..30b9a1ded2 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/serialization/strings/FastStringCodecTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/serialization/strings/FastStringCodecTest.java
@@ -26,7 +26,8 @@ public class FastStringCodecTest extends AbstractObjectCodecTest<String> {
public FastStringCodecTest() {
super(
- new FastStringCodec(),
+ // TODO(michajlo): Don't bother running this test if FastStringCodec isn't available.
+ FastStringCodec.isAvailable() ? new FastStringCodec() : new StringCodec(),
"ow now brown cow. ow now brown cow",
"(╯°□°)╯︵┻━┻ string with utf8/ascii",
"string with ascii/utf8 (╯°□°)╯︵┻━┻",
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/serialization/strings/StringCodecsTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/serialization/strings/StringCodecsTest.java
new file mode 100644
index 0000000000..52c50fc8ab
--- /dev/null
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/serialization/strings/StringCodecsTest.java
@@ -0,0 +1,36 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.devtools.build.lib.skyframe.serialization.strings;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/** {@link StringCodecs} tests */
+@RunWith(JUnit4.class)
+public class StringCodecsTest {
+
+ @Test
+ public void testUsesFastStringCodecIfAvailable() {
+ if (FastStringCodec.isAvailable()) {
+ assertThat(StringCodecs.asciiOptimized()).isInstanceOf(FastStringCodec.class);
+ } else {
+ assertThat(StringCodecs.asciiOptimized()).isSameAs(StringCodecs.simple());
+ }
+ }
+
+}