~ubuntu-branches/ubuntu/trusty/llvm-toolchain-snapshot/trusty-201310232150

« back to all changes in this revision

Viewing changes to clang/unittests/Tooling/RefactoringTest.cpp

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-27 15:01:57 UTC
  • mfrom: (0.10.1) (0.9.1) (0.8.1) (0.7.1) (0.6.1) (0.5.2)
  • Revision ID: package-import@ubuntu.com-20130527150157-tdkrsjpuvht7v0qx
Tags: 1:3.4~svn182733-1~exp1
* New snapshot release (3.4 release)
* Add a symlink of libLLVM-3.4.so.1 to usr/lib/llvm-3.4/lib/libLLVM-3.4.so
    to fix make the llvm-config-3.4 --libdir work (Closes: #708677)
  * Various packages rename to allow co installations:
    * libclang1 => libclang1-3.4
    * libclang1-dbg => libclang1-3.4-dbg
    * libclang-dev => libclang-3.4-dev
    * libclang-common-dev => libclang-common-3.4-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
151
151
  EXPECT_EQ("z", Context.getRewrittenText(IDz));
152
152
}
153
153
 
 
154
TEST(ShiftedCodePositionTest, FindsNewCodePosition) {
 
155
  Replacements Replaces;
 
156
  Replaces.insert(Replacement("", 0, 1, ""));
 
157
  Replaces.insert(Replacement("", 4, 3, " "));
 
158
  // Assume ' int   i;' is turned into 'int i;' and cursor is located at '|'.
 
159
  EXPECT_EQ(0u, shiftedCodePosition(Replaces, 0)); // |int   i;
 
160
  EXPECT_EQ(0u, shiftedCodePosition(Replaces, 1)); //  |nt   i;
 
161
  EXPECT_EQ(1u, shiftedCodePosition(Replaces, 2)); //  i|t   i;
 
162
  EXPECT_EQ(2u, shiftedCodePosition(Replaces, 3)); //  in|   i;
 
163
  EXPECT_EQ(3u, shiftedCodePosition(Replaces, 4)); //  int|  i;
 
164
  EXPECT_EQ(4u, shiftedCodePosition(Replaces, 5)); //  int | i;
 
165
  EXPECT_EQ(4u, shiftedCodePosition(Replaces, 6)); //  int  |i;
 
166
  EXPECT_EQ(4u, shiftedCodePosition(Replaces, 7)); //  int   |;
 
167
  EXPECT_EQ(5u, shiftedCodePosition(Replaces, 8)); //  int   i|
 
168
}
 
169
 
 
170
TEST(ShiftedCodePositionTest, FindsNewCodePositionWithInserts) {
 
171
  Replacements Replaces;
 
172
  Replaces.insert(Replacement("", 4, 0, "\"\n\""));
 
173
  // Assume '"12345678"' is turned into '"1234"\n"5678"'.
 
174
  EXPECT_EQ(4u, shiftedCodePosition(Replaces, 4)); // "123|5678"
 
175
  EXPECT_EQ(8u, shiftedCodePosition(Replaces, 5)); // "1234|678"
 
176
}
 
177
 
154
178
class FlushRewrittenFilesTest : public ::testing::Test {
155
179
 public:
156
180
  FlushRewrittenFilesTest() {