Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Hays <ianha@microsoft.com>2016-01-14 21:27:37 +0300
committerIan Hays <ianha@microsoft.com>2016-01-14 21:28:03 +0300
commit2a627b374ff097c51f9b6963da1b5d378eb2f2dc (patch)
tree13d1e5dc2489d4aa87fec6f92240ba66954da791 /src/System.IO/tests/StringReader/StringReader.CtorTests.cs
parent0f1378664ef590a76a635df0828ca878db395dae (diff)
Normalize System.IO.Tests namespaces and simplified types where possible.
Diffstat (limited to 'src/System.IO/tests/StringReader/StringReader.CtorTests.cs')
-rw-r--r--src/System.IO/tests/StringReader/StringReader.CtorTests.cs147
1 files changed, 147 insertions, 0 deletions
diff --git a/src/System.IO/tests/StringReader/StringReader.CtorTests.cs b/src/System.IO/tests/StringReader/StringReader.CtorTests.cs
new file mode 100644
index 0000000000..d1b0214ac7
--- /dev/null
+++ b/src/System.IO/tests/StringReader/StringReader.CtorTests.cs
@@ -0,0 +1,147 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System;
+using System.IO;
+using Xunit;
+
+namespace System.IO.Tests
+{
+ public class ReaderTests
+ {
+ [Fact]
+ public static void StringReaderWithNullString()
+ {
+ Assert.Throws<ArgumentNullException>(() => new StringReader(null));
+ }
+
+ [Fact]
+ public static void StringReaderWithEmptyString()
+ {
+
+ // [] Check vanilla construction
+ //-----------------------------------------------------------
+ StringReader sr = new StringReader(string.Empty);
+ Assert.Equal(string.Empty, sr.ReadToEnd());
+ }
+
+ [Fact]
+ public static void StringReaderWithGenericString()
+ {
+ // [] Another vanilla construction
+ //-----------------------------------------------------------
+
+ StringReader sr = new StringReader("Hello\0World");
+ Assert.Equal("Hello\0World", sr.ReadToEnd());
+ }
+
+ [Fact]
+ public static void ReadEmtpyString() {
+ StringReader sr = new StringReader(string.Empty);
+ Assert.Equal(-1, sr.Read());
+
+ }
+
+ [Fact]
+ public static void ReadString() {
+ string str1 = "Hello\0\t\v \\ World";
+ StringReader sr = new StringReader(str1);
+ for (int i = 0; i < str1.Length; i++)
+ {
+ Assert.Equal((int)str1[i], sr.Read());
+ }
+
+ }
+
+ [Fact]
+ public static void ReadPsudoRandomString()
+ {
+ string str1 = string.Empty;
+ Random r = new Random(-55);
+ for (int i = 0; i < 5000; i++)
+ str1 += (char)r.Next(0, 255);
+
+ StringReader sr = new StringReader(str1);
+ for (int i = 0; i < str1.Length; i++)
+ {
+ Assert.Equal((int)str1[i], sr.Read());
+ }
+ }
+
+
+
+
+
+ [Fact]
+ public static void PeedEmtpyString()
+ {
+ StringReader sr = new StringReader(string.Empty);
+ Assert.Equal(-1, sr.Peek());
+
+ }
+
+ [Fact]
+ public static void PeekString()
+ {
+ string str1 = "Hello\0\t\v \\ World";
+ StringReader sr = new StringReader(str1);
+ for (int i = 0; i < str1.Length; i++)
+ {
+ int test = sr.Peek();
+ sr.Read();
+ Assert.Equal((int)str1[i], test);
+ }
+
+ }
+
+ [Fact]
+ public static void PeekPsudoRandomString()
+ {
+ string str1 = string.Empty;
+ Random r = new Random(-55);
+ for (int i = 0; i < 5000; i++)
+ str1 += (char)r.Next(0, 255);
+
+ StringReader sr = new StringReader(str1);
+ for (int i = 0; i < str1.Length; i++)
+ {
+ int test = sr.Peek();
+ sr.Read();
+ Assert.Equal((int)str1[i], test);
+ }
+ }
+
+ [Fact]
+ public static void ReadToEndEmptyString()
+ {
+ ///////////////////////// START TESTS ////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+
+ StringReader sr;
+
+ sr = new StringReader(string.Empty);
+ Assert.Equal(string.Empty, sr.ReadToEnd());
+
+ }
+
+ [Fact]
+ public static void ReadToEndString() {
+ string str1 = "Hello\0\t\v \\ World";
+ StringReader sr = new StringReader(str1);
+ Assert.Equal(str1, sr.ReadToEnd());
+ }
+
+ [Fact]
+ public static void ReadToEndPsuedoRandom() {
+ // [] Try with large random strings
+ //-----------------------------------------------------------
+ string str1 = string.Empty;
+ Random r = new Random(-55);
+ for (int i = 0; i < 10000; i++)
+ str1 += (char)r.Next(0, 255);
+
+ StringReader sr = new StringReader(str1);
+ Assert.Equal(str1, sr.ReadToEnd());
+ }
+ }
+}