[PATCH] scrrun/tests: Add some tests for ReadLine()
Nikolay Sivov
nsivov at codeweavers.com
Wed Dec 27 04:49:33 CST 2017
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/scrrun/tests/filesystem.c | 78 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 78 insertions(+)
diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c
index d0c448c085..fd8d0bc5ad 100644
--- a/dlls/scrrun/tests/filesystem.c
+++ b/dlls/scrrun/tests/filesystem.c
@@ -2217,6 +2217,83 @@ static void test_GetSpecialFolder(void)
IFolder_Release(folder);
}
+static void test_ReadLine(void)
+{
+ static const WCHAR testW[] = {'a','\r','\n','b','c','\n','d','\r','e','\n','\r','f',0};
+ static const WCHAR line1W[] = {'a',0};
+ static const WCHAR line2W[] = {'b','c',0};
+ static const WCHAR line3W[] = {'d','\r','e',0};
+ static const WCHAR line4W[] = {'\r','f',0};
+ WCHAR pathW[MAX_PATH], dirW[MAX_PATH];
+ ITextStream *stream;
+ BSTR str, name;
+ HRESULT hr;
+ BOOL ret;
+
+ get_temp_filepath(testfileW, pathW, dirW);
+
+ ret = CreateDirectoryW(dirW, NULL);
+ ok(ret, "Failed to create test directory, error %d\n", GetLastError());
+
+ name = SysAllocString(pathW);
+ hr = IFileSystem3_CreateTextFile(fs3, name, VARIANT_FALSE, VARIANT_FALSE, &stream);
+ ok(hr == S_OK, "Failed to create file stream, hr %#x.\n", hr);
+
+ str = SysAllocString(testW);
+ hr = ITextStream_Write(stream, str);
+ ok(hr == S_OK, "Failed to write to the stream, hr %#x.\n", hr);
+ SysFreeString(str);
+
+ ITextStream_Release(stream);
+
+ hr = IFileSystem3_OpenTextFile(fs3, name, ForReading, VARIANT_FALSE, TristateFalse, &stream);
+ ok(hr == S_OK, "Failed to open file stream, hr %#x.\n", hr);
+
+todo_wine {
+ str = NULL;
+ hr = ITextStream_ReadLine(stream, &str);
+ ok(hr == S_OK, "Failed to read text line, hr %#x.\n", hr);
+ ok(str != NULL, "got %p\n", str);
+ ok(!lstrcmpW(line1W, str), "Unexpected line %s.\n", wine_dbgstr_w(str));
+ SysFreeString(str);
+
+ str = NULL;
+ hr = ITextStream_ReadLine(stream, &str);
+ ok(hr == S_OK, "Failed to read text line, hr %#x.\n", hr);
+ ok(str != NULL, "got %p\n", str);
+ ok(!lstrcmpW(line2W, str), "Unexpected line %s.\n", wine_dbgstr_w(str));
+ SysFreeString(str);
+
+ str = NULL;
+ hr = ITextStream_ReadLine(stream, &str);
+ ok(hr == S_OK, "Failed to read text line, hr %#x.\n", hr);
+ ok(str != NULL, "got %p\n", str);
+ ok(!lstrcmpW(line3W, str), "Unexpected line %s.\n", wine_dbgstr_w(str));
+ SysFreeString(str);
+
+ str = NULL;
+ hr = ITextStream_ReadLine(stream, &str);
+ ok(hr == S_FALSE, "Failed to read text line, hr %#x.\n", hr);
+ ok(str != NULL, "got %p\n", str);
+ ok(!lstrcmpW(line4W, str), "Unexpected line %s.\n", wine_dbgstr_w(str));
+ SysFreeString(str);
+}
+ hr = ITextStream_ReadLine(stream, NULL);
+ ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
+
+ str = (void *)0xdeadbeef;
+ hr = ITextStream_ReadLine(stream, &str);
+todo_wine
+ ok(hr == CTL_E_ENDOFFILE, "Unexpected hr %#x.\n", hr);
+ ok(!str, "Unexpected str %s\n", wine_dbgstr_w(str));
+
+ ITextStream_Release(stream);
+
+ DeleteFileW(name);
+ RemoveDirectoryW(dirW);
+ SysFreeString(name);
+}
+
START_TEST(filesystem)
{
HRESULT hr;
@@ -2255,6 +2332,7 @@ START_TEST(filesystem)
test_SerialNumber();
test_GetExtensionName();
test_GetSpecialFolder();
+ test_ReadLine();
IFileSystem3_Release(fs3);
--
2.15.1
More information about the wine-devel
mailing list