Last active
July 31, 2016 21:55
-
-
Save jayjacobs/ca53a484d1b8d7217ef8b4a3ecc5c00b to your computer and use it in GitHub Desktop.
getting public suffix list tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
connection <- url("https://raw.githubusercontent.com/publicsuffix/list/master/tests/test_psl.txt", method = "libcurl") | |
results <- readLines(connection) | |
close(connection) | |
justtests <- grep('checkPublicSuffix\\(', results, value = TRUE) | |
alltests <- do.call(rbind, lapply(strsplit(justtests, "'", fixed = TRUE), function(line) { | |
data.frame(domain=line[2], result=line[4]) | |
})) | |
domains <- suffix_extract(alltests$domain) | |
rez1 <-ifelse(!is.na(domains$domain), paste0(domains$domain, "."), "") | |
rez <- ifelse(!is.na(domains$suffix), paste0(rez1, domains$suffix), NA) | |
fullrez <- data.frame(got = rez, expected = alltests$result, stringsAsFactors = FALSE) | |
fullrez$check <- fullrez$got == fullrez$expected | |
fullrez$check <- ifelse(is.na(fullrez$got) & is.na(fullrez$expected), TRUE, fullrez$check) | |
fullrez$check <- ifelse(is.na(fullrez$check), FALSE, fullrez$check) | |
cat("Failed:", sum(!fullrez$check), "out of", nrow(fullrez)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment