Index: third_party/grpc/test/core/support/host_port_test.c |
diff --git a/third_party/WebKit/Source/platform/image-encoders/skia/WEBPImageEncoder.h b/third_party/grpc/test/core/support/host_port_test.c |
similarity index 58% |
copy from third_party/WebKit/Source/platform/image-encoders/skia/WEBPImageEncoder.h |
copy to third_party/grpc/test/core/support/host_port_test.c |
index cf1e8bde7e0ec66d9eaa32e35bb057e8e72b8b3e..eccc39a2db113bf638edf4684751d1ba8039306f 100644 |
--- a/third_party/WebKit/Source/platform/image-encoders/skia/WEBPImageEncoder.h |
+++ b/third_party/grpc/test/core/support/host_port_test.c |
@@ -1,5 +1,7 @@ |
/* |
- * Copyright (c) 2011, 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,28 +28,46 @@ |
* 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. |
+ * |
*/ |
-#ifndef WEBPImageEncoder_h |
-#define WEBPImageEncoder_h |
+#include <string.h> |
-#include "wtf/Allocator.h" |
-#include "wtf/Vector.h" |
+#include <grpc/support/alloc.h> |
+#include <grpc/support/host_port.h> |
+#include <grpc/support/log.h> |
+#include "test/core/util/test_config.h" |
-namespace blink { |
+static void join_host_port_expect(const char *host, int port, |
+ const char *expected) { |
+ char *buf; |
+ int len; |
+ len = gpr_join_host_port(&buf, host, port); |
+ GPR_ASSERT(len >= 0); |
+ GPR_ASSERT(strlen(expected) == (size_t)len); |
+ GPR_ASSERT(strcmp(expected, buf) == 0); |
+ gpr_free(buf); |
+} |
-struct ImageDataBuffer; |
+static void test_join_host_port(void) { |
+ join_host_port_expect("foo", 101, "foo:101"); |
+ join_host_port_expect("", 102, ":102"); |
+ join_host_port_expect("1::2", 103, "[1::2]:103"); |
+ join_host_port_expect("[::1]", 104, "[::1]:104"); |
+} |
-class WEBPImageEncoder { |
- STATIC_ONLY(WEBPImageEncoder); |
-public: |
- // Encode the input data with a compression quality in [0-100]. |
- static bool encode(const ImageDataBuffer&, int quality, Vector<unsigned char>*); |
+/* Garbage in, garbage out. */ |
+static void test_join_host_port_garbage(void) { |
+ join_host_port_expect("[foo]", 105, "[foo]:105"); |
+ join_host_port_expect("[::", 106, "[:::106"); |
+ join_host_port_expect("::]", 107, "[::]]:107"); |
+} |
- // For callers: provide a reasonable compression quality default. |
- enum Quality { DefaultCompressionQuality = 80 }; |
-}; |
+int main(int argc, char **argv) { |
+ grpc_test_init(argc, argv); |
-} // namespace blink |
+ test_join_host_port(); |
+ test_join_host_port_garbage(); |
-#endif |
+ return 0; |
+} |