Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1094)

Unified Diff: tests/standalone/src/SocketExceptionTest.dart

Issue 9572005: Move all tests using dart:io to a separate directory (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/standalone/src/SocketCloseTest.dart ('k') | tests/standalone/src/SocketManyConnectionsTest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/src/SocketExceptionTest.dart
diff --git a/tests/standalone/src/SocketExceptionTest.dart b/tests/standalone/src/SocketExceptionTest.dart
deleted file mode 100644
index edc78d0723169e6b9e0d902903e01c931dc7987e..0000000000000000000000000000000000000000
--- a/tests/standalone/src/SocketExceptionTest.dart
+++ /dev/null
@@ -1,180 +0,0 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-//
-// Tests socket exceptions.
-
-#import("dart:io");
-
-class SocketExceptionTest {
-
- static final PORT = 0;
- static final HOST = "127.0.0.1";
-
- static void serverSocketExceptionTest() {
- bool exceptionCaught = false;
- bool wrongExceptionCaught = false;
-
- ServerSocket server = new ServerSocket(HOST, PORT, 10);
- Expect.equals(true, server !== null);
- server.close();
- try {
- server.close();
- } catch (SocketIOException ex) {
- exceptionCaught = true;
- } catch (Exception ex) {
- wrongExceptionCaught = true;
- }
- Expect.equals(false, exceptionCaught);
- Expect.equals(true, !wrongExceptionCaught);
- }
-
- static void clientSocketExceptionTest() {
- bool exceptionCaught = false;
- bool wrongExceptionCaught = false;
-
- ServerSocket server = new ServerSocket(HOST, PORT, 10);
- Expect.equals(true, server !== null);
- int port = server.port;
- Socket client = new Socket(HOST, port);
- Expect.equals(true, client !== null);
- InputStream input = client.inputStream;
- OutputStream output = client.outputStream;
- client.close();
- try {
- client.close();
- } catch (SocketIOException ex) {
- exceptionCaught = true;
- } catch (Exception ex) {
- wrongExceptionCaught = true;
- }
- Expect.equals(false, exceptionCaught);
- Expect.equals(true, !wrongExceptionCaught);
- exceptionCaught = false;
- try {
- client.available();
- } catch (SocketIOException ex) {
- exceptionCaught = true;
- } catch (Exception ex) {
- wrongExceptionCaught = true;
- }
- Expect.equals(true, exceptionCaught);
- Expect.equals(true, !wrongExceptionCaught);
- exceptionCaught = false;
- try {
- List<int> buffer = new List<int>(10);
- client.readList(buffer, 0 , 10);
- } catch (SocketIOException ex) {
- exceptionCaught = true;
- } catch (Exception ex) {
- wrongExceptionCaught = true;
- }
- Expect.equals(true, exceptionCaught);
- Expect.equals(true, !wrongExceptionCaught);
- exceptionCaught = false;
- try {
- List<int> buffer = new List<int>(10);
- client.writeList(buffer, 0, 10);
- } catch (SocketIOException ex) {
- exceptionCaught = true;
- } catch (Exception ex) {
- wrongExceptionCaught = true;
- }
- Expect.equals(true, exceptionCaught);
- Expect.equals(true, !wrongExceptionCaught);
- exceptionCaught = false;
- try {
- List<int> buffer = new List<int>(42);
- bool readDone = input.readInto(buffer, 0, 12);
- } catch (SocketIOException ex) {
- exceptionCaught = true;
- } catch (Exception ex) {
- wrongExceptionCaught = true;
- }
- Expect.equals(true, exceptionCaught);
- Expect.equals(true, !wrongExceptionCaught);
- exceptionCaught = false;
- try {
- List<int> buffer = new List<int>(42);
- output.writeFrom(buffer, 0, 12);
- } catch (SocketIOException ex) {
- exceptionCaught = true;
- } catch (Exception ex) {
- wrongExceptionCaught = true;
- }
- Expect.equals(true, exceptionCaught);
- Expect.equals(true, !wrongExceptionCaught);
-
- server.close();
- }
-
- static void indexOutOfRangeExceptionTest() {
- bool exceptionCaught = false;
- bool wrongExceptionCaught = false;
-
- ServerSocket server = new ServerSocket(HOST, PORT, 10);
- Expect.equals(true, server !== null);
- int port = server.port;
- Socket client = new Socket(HOST, port);
- Expect.equals(true, client !== null);
- try {
- List<int> buffer = new List<int>(10);
- client.readList(buffer, -1, 1);
- } catch (IndexOutOfRangeException ex) {
- exceptionCaught = true;
- } catch (Exception ex) {
- wrongExceptionCaught = true;
- }
- Expect.equals(true, exceptionCaught);
- Expect.equals(true, !wrongExceptionCaught);
- exceptionCaught = false;
-
- try {
- List<int> buffer = new List<int>(10);
- client.readList(buffer, 0, -1);
- } catch (IndexOutOfRangeException ex) {
- exceptionCaught = true;
- } catch (Exception ex) {
- wrongExceptionCaught = true;
- }
- Expect.equals(true, exceptionCaught);
- Expect.equals(true, !wrongExceptionCaught);
- exceptionCaught = false;
-
- try {
- List<int> buffer = new List<int>(10);
- client.writeList(buffer, -1, 1);
- } catch (IndexOutOfRangeException ex) {
- exceptionCaught = true;
- } catch (Exception ex) {
- wrongExceptionCaught = true;
- }
- Expect.equals(true, exceptionCaught);
- Expect.equals(true, !wrongExceptionCaught);
- exceptionCaught = false;
-
- try {
- List<int> buffer = new List<int>(10);
- client.writeList(buffer, 0, -1);
- } catch (IndexOutOfRangeException ex) {
- exceptionCaught = true;
- } catch (Exception ex) {
- wrongExceptionCaught = true;
- }
- Expect.equals(true, exceptionCaught);
- Expect.equals(true, !wrongExceptionCaught);
-
- server.close();
- client.close();
- }
-
- static void testMain() {
- serverSocketExceptionTest();
- clientSocketExceptionTest();
- indexOutOfRangeExceptionTest();
- }
-}
-
-main() {
- SocketExceptionTest.testMain();
-}
« no previous file with comments | « tests/standalone/src/SocketCloseTest.dart ('k') | tests/standalone/src/SocketManyConnectionsTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698