testStringBuilder.cpp (852B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- 2 * vim: set ts=8 sts=2 et sw=2 tw=80: 3 */ 4 /* This Source Code Form is subject to the terms of the Mozilla Public 5 * License, v. 2.0. If a copy of the MPL was not distributed with this 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 7 8 #include "jsapi-tests/tests.h" 9 #include "util/StringBuilder.h" 10 #include "vm/JSAtomUtils.h" // AtomizeString 11 12 BEGIN_TEST(testStringBuilder_finishString) { 13 JSString* str = JS_NewStringCopyZ(cx, "foopy"); 14 CHECK(str); 15 16 JS::Rooted<JSAtom*> atom(cx, js::AtomizeString(cx, str)); 17 CHECK(atom); 18 19 js::StringBuilder sb(cx); 20 CHECK(sb.append("foopy")); 21 22 JS::Rooted<JSAtom*> finishedAtom(cx, sb.finishAtom()); 23 CHECK(finishedAtom); 24 CHECK_EQUAL(atom, finishedAtom); 25 return true; 26 } 27 END_TEST(testStringBuilder_finishString)