13d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// Protocol Buffers - Google's data interchange format 23d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// Copyright 2008 Google Inc. All rights reserved. 33d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// http://code.google.com/p/protobuf/ 43d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// 53d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// Redistribution and use in source and binary forms, with or without 63d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// modification, are permitted provided that the following conditions are 73d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// met: 83d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// 93d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// * Redistributions of source code must retain the above copyright 103d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// notice, this list of conditions and the following disclaimer. 113d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// * Redistributions in binary form must reproduce the above 123d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// copyright notice, this list of conditions and the following disclaimer 133d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// in the documentation and/or other materials provided with the 143d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// distribution. 153d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// * Neither the name of Google Inc. nor the names of its 163d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// contributors may be used to endorse or promote products derived from 173d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// this software without specific prior written permission. 183d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// 193d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 203d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 213d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 223d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 233d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 243d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 253d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 263d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 273d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 283d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 293d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 303d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch 313d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// Author: kenton@google.com (Kenton Varda) 323d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch 333d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch#include <google/protobuf/compiler/java/java_doc_comment.h> 343d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch 353d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch#include <gtest/gtest.h> 363d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch 373d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdochnamespace google { 383d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdochnamespace protobuf { 393d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdochnamespace compiler { 403d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdochnamespace java { 413d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdochnamespace { 423d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch 433d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben MurdochTEST(JavaDocCommentTest, Escaping) { 443d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch EXPECT_EQ("foo /* bar */ baz", EscapeJavadoc("foo /* bar */ baz")); 453d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch EXPECT_EQ("foo /*/ baz", EscapeJavadoc("foo /*/ baz")); 463d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch EXPECT_EQ("{@foo}", EscapeJavadoc("{@foo}")); 473d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch EXPECT_EQ("<i>&</i>", EscapeJavadoc("<i>&</i>")); 483d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch EXPECT_EQ("foo\u1234bar", EscapeJavadoc("foo\\u1234bar")); 493d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch} 503d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch 513d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// TODO(kenton): It's hard to write a robust test of the doc comments -- we 523d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// can only really compare the output against a golden value, which is a 533d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// fairly tedious and fragile testing strategy. If we want to go that route, 543d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// it probably makes sense to bite the bullet and write a test that compares 553d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// the whole generated output for unittest.proto against a golden value, with 563d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// a very simple script that can be run to regenerate it with the latest code. 573d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// This would mean that updates to the golden file would have to be included 583d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// in any change to the code generator, which would actually be fairly useful 593d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// as it allows the reviewer to see clearly how the generated code is 603d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch// changing. 613d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch 623d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch} // namespace 633d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch} // namespace java 643d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch} // namespace compiler 653d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch} // namespace protobuf 663d4dfb6f11fb4e934d658743a8efc26d5490fdb0Ben Murdoch} // namespace google 67