Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Unified Diff: server/config/caching/codec_test.go

Issue 2573403002: server/config: Generic caching backend. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: server/config/caching/codec_test.go
diff --git a/server/config/caching/codec_test.go b/server/config/caching/codec_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..3c5ed08bf6fdeb4317fc8cbe02888411196d1db8
--- /dev/null
+++ b/server/config/caching/codec_test.go
@@ -0,0 +1,31 @@
+// Copyright 2015 The LUCI Authors. All rights reserved.
+// Use of this source code is governed under the Apache License, Version 2.0
+// that can be found in the LICENSE file.
+
+package caching
+
+import (
+ "testing"
+
+ . "github.com/smartystreets/goconvey/convey"
+)
+
+func TestHashParams(t *testing.T) {
+ t.Parallel()
+
+ Convey(`Testing HashParams`, t, func() {
+ // Can't cheat w/ strings including "\x00" (escaping).
+ //
+ // Without escaping:
+ // ["A\x00B"] => A 0x00 B 0x00
+ // ["A" "B"] => A 0x00 B 0x00
+ So(HashParams("A\x00B"), ShouldNotResemble, HashParams("A", "B"))
+
+ // Can't cheat with different lengths (length prefix).
+ //
+ // After escaping, but with no length prefix:
+ // ["A\x00" ""] => A 0x00 0x00 0x00 0x00
+ // ["A" "" "" ""] => A 0x00 0x00 0x00 0x00
+ So(HashParams("A\x00", ""), ShouldNotResemble, HashParams("A", "", "", ""))
+ })
+}

Powered by Google App Engine
This is Rietveld 408576698