2 * Back 2 Browser Bytecode Translator
3 * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 2 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. Look for COPYING file in the top folder.
16 * If not, see http://opensource.org/licenses/GPL-2.0.
18 package org.apidesign.bck2brwsr.tck;
20 import java.net.MalformedURLException;
22 import org.apidesign.bck2brwsr.vmtest.Compare;
23 import org.apidesign.bck2brwsr.vmtest.VMTest;
24 import org.testng.annotations.Factory;
28 * @author Jaroslav Tulach <jtulach@netbeans.org>
30 public class CompareStringsTest {
31 @Compare public static Object compareURLs() throws MalformedURLException {
32 return new URL("http://apidesign.org:8080/wiki/").toExternalForm().toString();
35 @Compare public String deleteLastTwoCharacters() {
36 StringBuilder sb = new StringBuilder();
38 if (sb.toString().endsWith(".0")) {
39 final int l = sb.length();
42 return sb.toString().toString();
45 @Compare public String nameOfStringClass() throws Exception {
46 return Class.forName("java.lang.String").getName();
48 @Compare public String nameOfArrayClass() throws Exception {
49 return Class.forName("org.apidesign.bck2brwsr.tck.CompareHashTest").getName();
52 @Compare public String lowerHello() {
53 return "HeLlO".toLowerCase();
56 @Compare public String lowerA() {
57 return String.valueOf(Character.toLowerCase('A')).toString();
59 @Compare public String upperHello() {
60 return "hello".toUpperCase();
63 @Compare public String upperA() {
64 return String.valueOf(Character.toUpperCase('a')).toString();
67 @Compare public boolean matchRegExp() throws Exception {
68 return "58038503".matches("\\d*");
71 @Compare public boolean doesNotMatchRegExp() throws Exception {
72 return "58038503GH".matches("\\d*");
75 @Compare public boolean doesNotMatchRegExpFully() throws Exception {
76 return "Hello".matches("Hell");
79 @Compare public String variousCharacterTests() throws Exception {
80 StringBuilder sb = new StringBuilder();
82 sb.append(Character.isUpperCase('a'));
83 sb.append(Character.isUpperCase('A'));
84 sb.append(Character.isLowerCase('a'));
85 sb.append(Character.isLowerCase('A'));
87 sb.append(Character.isLetter('A'));
88 sb.append(Character.isLetterOrDigit('9'));
89 sb.append(Character.isLetterOrDigit('A'));
90 sb.append(Character.isLetter('0'));
92 return sb.toString().toString();
96 public String nullFieldInitialized() {
97 NullField nf = new NullField();
98 return ("" + nf.name).toString();
102 public static Object[] create() {
103 return VMTest.create(CompareStringsTest.class);
106 private static final class NullField {