bool TestExtFile::test_feof() { Variant f = f_fopen("test/test_ext_file.tmp", "w"); f_fputs(f, "testing feof"); f_fclose(f); f = f_fopen("test/test_ext_file.tmp", "r"); VERIFY(!f_feof(f)); VS(f_fread(f, 20), "testing feof"); VERIFY(f_feof(f)); return Count(true); }
bool TestExtNetwork::test_fsockopen() { { Variant f = f_fsockopen("facebook.com", 80); VERIFY(!same(f, false)); f_fputs(f, "GET / HTTP/1.0\n\n"); VERIFY(!f_fread(f, 15).toString().empty()); } { Variant f = f_fsockopen("ssl://www.facebook.com", 443); VERIFY(!same(f, false)); f_fwrite(f, "GET / HTTP/1.1\r\n" "Host: www.facebook.com\r\n" "Connection: Close\r\n" "\r\n"); StringBuffer response; while (!same(f_feof(f), true)) { Variant line = f_fgets(f, 128); response.append(line.toString()); } VERIFY(!response.detach().empty()); } return Count(true); }