Index: third_party/grpc/test/core/transport/chttp2/varint_test.c |
diff --git a/third_party/WebKit/Source/modules/crypto/CryptoKey.idl b/third_party/grpc/test/core/transport/chttp2/varint_test.c |
similarity index 54% |
copy from third_party/WebKit/Source/modules/crypto/CryptoKey.idl |
copy to third_party/grpc/test/core/transport/chttp2/varint_test.c |
index 9cd28dd316d7f2ef13a42228011893a4771b1a8c..f06116a731b6851966853c2de49ddccbcd09473e 100644 |
--- a/third_party/WebKit/Source/modules/crypto/CryptoKey.idl |
+++ b/third_party/grpc/test/core/transport/chttp2/varint_test.c |
@@ -1,5 +1,7 @@ |
/* |
- * Copyright (C) 2013 Google Inc. All rights reserved. |
+ * |
+ * Copyright 2015, Google Inc. |
+ * All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions are |
@@ -26,13 +28,41 @@ |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+ * |
*/ |
-[ |
- Exposed=(Window,Worker) |
-] interface CryptoKey { |
- readonly attribute DOMString type; |
- readonly attribute boolean extractable; |
- [CallWith=ScriptState] readonly attribute object algorithm; |
- readonly attribute DOMString[] usages; |
-}; |
+#include "src/core/transport/chttp2/varint.h" |
+ |
+#include <grpc/support/log.h> |
+#include <grpc/support/slice.h> |
+ |
+#include "test/core/util/test_config.h" |
+ |
+static void test_varint(uint32_t value, uint32_t prefix_bits, uint8_t prefix_or, |
+ const char *expect_bytes, size_t expect_length) { |
+ uint32_t nbytes = GRPC_CHTTP2_VARINT_LENGTH(value, prefix_bits); |
+ gpr_slice expect = gpr_slice_from_copied_buffer(expect_bytes, expect_length); |
+ gpr_slice slice; |
+ gpr_log(GPR_DEBUG, "Test: 0x%08x", value); |
+ GPR_ASSERT(nbytes == expect_length); |
+ slice = gpr_slice_malloc(nbytes); |
+ GRPC_CHTTP2_WRITE_VARINT(value, prefix_bits, prefix_or, |
+ GPR_SLICE_START_PTR(slice), nbytes); |
+ GPR_ASSERT(gpr_slice_cmp(expect, slice) == 0); |
+ gpr_slice_unref(expect); |
+ gpr_slice_unref(slice); |
+} |
+ |
+#define TEST_VARINT(value, prefix_bits, prefix_or, expect) \ |
+ test_varint(value, prefix_bits, prefix_or, expect, sizeof(expect) - 1) |
+ |
+int main(int argc, char **argv) { |
+ grpc_test_init(argc, argv); |
+ TEST_VARINT(0, 1, 0, "\x00"); |
+ TEST_VARINT(128, 1, 0, "\x7f\x01"); |
+ TEST_VARINT(16384, 1, 0, "\x7f\x81\x7f"); |
+ TEST_VARINT(2097152, 1, 0, "\x7f\x81\xff\x7f"); |
+ TEST_VARINT(268435456, 1, 0, "\x7f\x81\xff\xff\x7f"); |
+ TEST_VARINT(0xffffffff, 1, 0, "\x7f\x80\xff\xff\xff\x0f"); |
+ return 0; |
+} |