/*
* @(#)CtorTests.java 1.21 01/06/06 16:04:22 Stanislav V. Avzan and Vladimir V. Sizikov
*
* Copyright (c) 1996-2000 Sun Microsystems, Inc. All Rights Reserved.
* This software is the confidential and proprietary information of Sun
* Microsystems, Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Sun.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
* THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
*
* Button constructor tests
* Testing Button creation
*/
package javasoft.sqe.tests.api.java.awt.Button;
import java.io.PrintWriter;
import javasoft.sqe.javatest.Status;
import javasoft.sqe.javatest.lib.MultiTest;
import java.awt.*;
public class CtorTests extends MultiTest {
/* standalone interface */
public static void main(String argv[]) {
CtorTests test = new CtorTests();
test.run(argv, System.err, System.out).exit();
}
/**
* Assertion testing
* for public Button(),
* Will create new Button object with the corresponding values..
*/
public Status Button2001() {
Button c = new Button(); // Create Button object
if (!(c != null // Test not null
&& c instanceof Button // Test instance
&& c.getLabel().equals("") // Test label is empty
)) {
return Status.failed("Failed to create Button object");
}
return Status.passed("OKAY");
}
/**
* Boundary value analysis
* with input values orientation
* for public Button(String label),
*
label: null.
*
Expected results: Should not throw NullPointerException.
*/
public Status Button1001() {
Button c = new Button(null); // Try to create Button object with null label
if (c != null // Test not null
&& c instanceof Button // Test instance
) {
return Status.passed("OKAY");
}
return Status.failed("Constructor works wrong");
}
/**
* Assertion testing
* for public Button(String label),
* Will create new Button object with the corresponding values..
*/
public Status Button2002() {
String[] labels = { "", "&", "^", "*+",
"#$%$#^$%^#$%#^$%^&%$&%$^%$#^#%$^$#%^$%#^$%#^$#%^$#%^$#%^$%#^$%^%$" ,
"\0\1\uFFFF", "simple label"
}; // Define some test labels
for (int i = 0; i < labels.length; i++) {
Button c = new Button(labels[i]); // Create Button object using label
if (!(c != null // Test not null
&& c instanceof Button // Test instance
&& c.getLabel().equals(labels[i]) // Test label is as expected
)) {
return Status.failed("Failed to test Button object");
}
}
return Status.passed("OKAY");
}
}