diff --git a/CMakeLists.txt b/CMakeLists.txt index 02a45b732..5d4ebb242 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ set(FAKER_SOURCES src/modules/animal/Animal.cpp src/modules/animal/AnimalData.cpp src/modules/book/Book.cpp + src/modules/book/BookData.cpp src/modules/color/Color.cpp src/modules/commerce/Commerce.cpp src/modules/company/Company.cpp diff --git a/include/faker-cxx/Book.h b/include/faker-cxx/Book.h index 4f5649c3a..ff4535fcf 100644 --- a/include/faker-cxx/Book.h +++ b/include/faker-cxx/Book.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace faker { @@ -16,7 +16,7 @@ class Book * Book::title() // "Romeo and Juliet" * @endcode */ - static std::string title(); + static std::string_view title(); /** * @brief Returns a random book genre. @@ -27,7 +27,7 @@ class Book * Book::genre() // "Fantasy" * @endcode */ - static std::string genre(); + static std::string_view genre(); /** * @brief Returns a random book author. @@ -38,7 +38,7 @@ class Book * Book::author() // "Shakespeare, William" * @endcode */ - static std::string author(); + static std::string_view author(); /** * @brief Returns a random book publisher. @@ -49,7 +49,7 @@ class Book * Book::publisher() // "Addison-Wesley" * @endcode */ - static std::string publisher(); + static std::string_view publisher(); /** * @brief Returns a random book ISBN. @@ -62,27 +62,16 @@ class Book */ static std::string isbn(); - /** - * @brief Returns a random release year - * - * @returns int year - * - * @code - * Book::releaseYear() // 2016 - * @endcode - */ - static int releaseYear(); - /** * @brief Returns the full name of a translator * - * @returns std::string full name + * @returns std::string_view full name * * @code * Book::translator() // "Eric Floyd" * @endcode */ - static std::string translator(); + static std::string_view translator(); /** * @brief Returns format of book @@ -93,28 +82,17 @@ class Book * Book::format() // BookFormat::paperback * @endcode */ - static std::string format(); - - /** - * @brief returns a random page number (50-999) - * - * @returns int page number - * - * @code - * Book::page() // 314 - * @endcode - */ - static int page(); + static std::string_view format(); /** * @brief returns a random book series * - * @returns std::string book series + * @returns std::string_view book series * * @code * Book::series() // "Harry Potter" * @endcode */ - static std::string series(); + static std::string_view series(); }; } diff --git a/src/modules/book/Book.cpp b/src/modules/book/Book.cpp index 4b939beaf..934a7d62c 100644 --- a/src/modules/book/Book.cpp +++ b/src/modules/book/Book.cpp @@ -1,38 +1,31 @@ #include "faker-cxx/Book.h" #include "../../common/FormatHelper.h" -#include "data/Authors.h" -#include "data/BookFormat.h" -#include "data/Genres.h" -#include "data/Publishers.h" -#include "data/Series.h" -#include "data/Titles.h" -#include "data/Translators.h" -#include "faker-cxx/Date.h" +#include "BookData.h" #include "faker-cxx/Helper.h" #include "faker-cxx/Number.h" #include "faker-cxx/String.h" namespace faker { -std::string Book::title() +std::string_view Book::title() { - return Helper::arrayElement(titles); + return Helper::arrayElement(titles); } -std::string Book::genre() +std::string_view Book::genre() { - return Helper::arrayElement(genres); + return Helper::arrayElement(genres); } -std::string Book::author() +std::string_view Book::author() { - return Helper::arrayElement(authors); + return Helper::arrayElement(authors); } -std::string Book::publisher() +std::string_view Book::publisher() { - return Helper::arrayElement(publishers); + return Helper::arrayElement(publishers); } std::string Book::isbn() @@ -41,28 +34,18 @@ std::string Book::isbn() String::numeric(5), String::numeric(1)); } -int Book::releaseYear() +std::string_view Book::translator() { - return Number::integer(1940, 2024); + return Helper::arrayElement(translators); } -std::string Book::translator() +std::string_view Book::format() { - return Helper::arrayElement(translators); + return Helper::arrayElement(bookFormats); } -std::string Book::format() +std::string_view Book::series() { - return Helper::arrayElement(bookFormats); -} - -int Book::page() -{ - return Number::integer(50, 999); -} - -std::string Book::series() -{ - return Helper::arrayElement(bookSeries); + return Helper::arrayElement(bookSeries); } } diff --git a/src/modules/book/BookData.cpp b/src/modules/book/BookData.cpp new file mode 100644 index 000000000..593016aea --- /dev/null +++ b/src/modules/book/BookData.cpp @@ -0,0 +1,531 @@ +#include "BookData.h" + +namespace faker +{ +const std::array authors = {"Shakespeare, William", + "Smollett, T. (Tobias)", + "Dumas, Alexandre", + "Montgomery, L. M. (Lucy Maud)", + "Melville, Herman", + "Alcott, Louisa May", + "Eliot, George", + "Forster, E. M. (Edward Morgan)", + "Austen, Jane", + "Merrill, Frank T.", + "Dickens, Charles", + "Gaskell, Elizabeth Cleghorn", + "Von Arnim, Elizabeth", + "Brock, C. E. (Charles Edmund)", + "Fielding, Henry", + "Wagner, Richard", + "Twain, Mark", + "Doyle, Arthur Conan", + "Dostoyevsky, Fyodor", + "Packard, Vance", + "Adams, Clifford R. (Clifford Rose)", + "Wilde, Oscar", + "Garnett, Constance", + "Carroll, Lewis", + "Nietzsche, Friedrich Wilhelm", + "Tolstoy, Leo", + "Stevenson, Robert Louis", + "Wells, H. G. (Herbert George)", + "Shelley, Mary Wollstonecraft", + "Howard, Robert E. (Robert Ervin)", + "Baum, L. Frank (Lyman Frank)", + "Chesterton, G. K. (Gilbert Keith)", + "Homer", + "Plato", + "Rizal, José", + "Christie, Agatha", + "Joyce, James", + "Jowett, Benjamin", + "Poe, Edgar Allan", + "Verne, Jules", + "Thoreau, Henry David", + "Kafka, Franz", + "Stoker, Bram", + "Kipling, Rudyard", + "Doré, Gustave", + "Widger, David", + "Fitzgerald, F. Scott (Francis Scott)", + "Russell, Bertrand", + "Swift, Jonathan", + "Dante Alighieri", + "Wyllie, David", + "Hugo, Victor", + "Lang, Andrew", + "Maude, Aylmer", + "Burton, Richard Francis, Sir", + "Maude, Louise", + "Hawthorne, Nathaniel", + "Conrad, Joseph", + "London, Jack", + "Goethe, Johann Wolfgang von", + "James, Henry", + "Scott, Walter", + "Chekhov, Anton Pavlovich", + "Pope, Alexander", + "Ibsen, Henrik", + "Cervantes Saavedra, Miguel de", + "Balzac, Honoré de", + "Grimm, Jacob", + "Grimm, Wilhelm", + "Lovecraft, H. P. (Howard Phillips)", + "Burroughs, Edgar Rice", + "Shaw, Bernard", + "Gilman, Charlotte Perkins", + "Wodehouse, P. G. (Pelham Grenville)", + "Hotten, John Camden", + "Morley, Henry", + "Machiavelli, Niccolò", + "Derbyshire, Charles E.", + "Barrie, J. M. (James Matthew)", + "Brontë, Charlotte", + "Defoe, Daniel", + "Ward, Grady", + "Levy, Oscar", + "Burnett, Frances Hodgson", + "Schopenhauer, Arthur", + "Buckley, Theodore Alois", + "Milne, A. A. (Alan Alexander)", + "Marriott, W. K. (William Kenaz)", + "Vatsyayana", + "Potter, Beatrix", + "Ormsby, John", + "Bhide, Shivaram Parashuram", + "Butler, Samuel", + "Indrajit, Bhagavanlal", + "Maupassant, Guy de", + "Hapgood, Isabel Florence", + "Chambers, Robert W. (Robert William)", + "Marx, Karl", + "Eliot, T. S. (Thomas Stearns)", + "Hardy, Thomas"}; + +const std::array bookFormats{ + "Paperback", + "Hardcover", + "Kindle", +}; + +const std::array genres = {"Adventure stories", + "Classics", + "Crime", + "Fairy tales, fables, and folk tales", + "Fantasy", + "Historical fiction", + "Horror", + "Humour and satire", + "Literary fiction", + "Mystery", + "Poetry", + "Plays", + "Romance", + "Science fiction", + "Short stories", + "Thrillers", + "War", + "Women’s fiction", + "Young adult", + "Non-fiction", + "Autobiography and memoir", + "Biography", + "Essays", + "Non-fiction novel", + "Self-help"}; + +const std::array publishers = {"Academic Press", + "Ace Books", + "Addison-Wesley", + "Adis International", + "Airiti Press", + "Andrews McMeel Publishing", + "Anova Books", + "Anvil Press Poetry", + "Applewood Books", + "Apress", + "Athabasca University Press", + "Atheneum Books", + "Atheneum Publishers", + "Atlantic Books", + "Atlas Press", + "Ballantine Books", + "Banner of Truth Trust", + "Bantam Books", + "Bantam Spectra", + "Barrie & Jenkins", + "Basic Books", + "BBC Books", + "Harvard University Press", + "Belknap Press", + "Bella Books", + "Bellevue Literary Press", + "Berg Publishers", + "Berkley Books", + "Bison Books", + "Black Dog Publishing", + "Black Library", + "Black Sparrow Books", + "Blackie and Son Limited", + "Blackstaff Press", + "Blackwell Publishing", + "John Blake Publishing", + "Bloodaxe Books", + "Bloomsbury Publishing Plc", + "Blue Ribbon Books", + "Book League of America", + "Book Works", + "Booktrope", + "Borgo Press", + "Bowes & Bowes", + "Boydell & Brewer", + "Breslov Research Institute", + "Brill Publishers", + "Brimstone Press", + "Broadview Press", + "Burns & Oates", + "Butterworth-Heinemann", + "Caister Academic Press", + "Cambridge University Press", + "Candlewick Press", + "Canongate Books", + "Carcanet Press", + "Carlton Books", + "Carlton Publishing Group", + "Carnegie Mellon University Press", + "Casemate Publishers", + "Cengage Learning", + "Central European University Press", + "Chambers Harrap", + "Charles Scribner's Sons", + "Chatto and Windus", + "Chick Publications", + "Chronicle Books", + "Churchill Livingstone", + "Cisco Press", + "City Lights Publishers", + "Cloverdale Corporation", + "D. Appleton & Company", + "D. Reidel", + "Da Capo Press", + "Daedalus Publishing", + "Dalkey Archive Press", + "Darakwon Press", + "David & Charles", + "DAW Books", + "Dedalus Books", + "Del Rey Books", + "E. P. Dutton", + "Earthscan", + "ECW Press", + "Eel Pie Publishing", + "Eerdmans Publishing", + "Edupedia Publications", + "Ellora's Cave", + "Elsevier", + "Emerald Group Publishing", + "Etruscan Press", + "Faber and Faber", + "FabJob", + "Fairview Press", + "Farrar, Straus & Giroux", + "Fearless Books", + "Felony & Mayhem Press", + "Firebrand Books", + "Flame Tree Publishing", + "Focal Press", + "G. P. Putnam's Sons", + "G-Unit Books", + "Gaspereau Press", + "Gay Men's Press", + "Gefen Publishing House", + "George H. Doran Company", + "George Newnes", + "George Routledge & Sons", + "Godwit Press", + "Golden Cockerel Press", + "Hachette Book Group USA", + "Hackett Publishing Company", + "Hamish Hamilton", + "Happy House", + "Harcourt Assessment", + "Harcourt Trade Publishers", + "Harlequin Enterprises Ltd", + "Harper & Brothers", + "Harper & Row", + "HarperCollins", + "HarperPrism", + "HarperTrophy", + "Harry N. Abrams, Inc.", + "Harvard University Press", + "Harvest House", + "Harvill Press at Random House", + "Hawthorne Books", + "Hay House", + "Haynes Manuals", + "Heyday Books", + "HMSO", + "Hodder & Stoughton", + "Hodder Headline", + "Hogarth Press", + "Holland Park Press", + "Holt McDougal", + "Horizon Scientific Press", + "Ian Allan Publishing", + "Ignatius Press", + "Imperial War Museum", + "Indiana University Press", + "J. M. Dent", + "Jaico Publishing House", + "Jarrolds Publishing", + "Karadi Tales", + "Kensington Books", + "Kessinger Publishing", + "Kodansha", + "Kogan Page", + "Koren Publishers Jerusalem", + "Ladybird Books", + "Leaf Books", + "Leafwood Publishers", + "Left Book Club", + "Legend Books", + "Lethe Press", + "Libertas Academica", + "Liberty Fund", + "Library of America", + "Lion Hudson", + "Macmillan Publishers", + "Mainstream Publishing", + "Manchester University Press", + "Mandrake of Oxford", + "Mandrake Press", + "Manning Publications", + "Manor House Publishing", + "Mapin Publishing", + "Marion Boyars Publishers", + "Mark Batty Publisher", + "Marshall Cavendish", + "Marshall Pickering", + "Martinus Nijhoff Publishers", + "Mascot Books", + "Matthias Media", + "McClelland and Stewart", + "McFarland & Company", + "McGraw-Hill Education", + "McGraw Hill Financial", + "Medknow Publications", + "Naiad Press", + "Nauka", + "NavPress", + "New Directions Publishing", + "New English Library", + "New Holland Publishers", + "New Village Press", + "Newnes", + "No Starch Press", + "Nonesuch Press", + "Oberon Books", + "Open Court Publishing Company", + "Open University Press", + "Orchard Books", + "O'Reilly Media", + "Orion Books", + "Packt Publishing", + "Palgrave Macmillan", + "Pan Books", + "Pantheon Books at Random House", + "Papadakis Publisher", + "Parachute Publishing", + "Parragon", + "Pathfinder Press", + "Paulist Press", + "Pavilion Books", + "Peace Hill Press", + "Pecan Grove Press", + "Pen and Sword Books", + "Penguin Books", + "Random House", + "Reed Elsevier", + "Reed Publishing", + "SAGE Publications", + "St. Martin's Press", + "Salt Publishing", + "Sams Publishing", + "Schocken Books", + "Scholastic Press", + "Charles Scribner's Sons", + "Seagull Books", + "Secker & Warburg", + "Shambhala Publications", + "Shire Books", + "Shoemaker & Hoard Publishers", + "Shuter & Shooter Publishers", + "Sidgwick & Jackson", + "Signet Books", + "Simon & Schuster", + "T & T Clark", + "Tachyon Publications", + "Tammi", + "Target Books", + "Tarpaulin Sky Press", + "Tartarus Press", + "Tate Publishing & Enterprises", + "Taunton Press", + "Taylor & Francis", + "Ten Speed Press", + "UCL Press", + "Unfinished Monument Press", + "United States Government Publishing Office", + "University of Akron Press", + "University of Alaska Press", + "University of California Press", + "University of Chicago Press", + "University of Michigan Press", + "University of Minnesota Press", + "University of Nebraska Press", + "Velazquez Press", + "Verso Books", + "Victor Gollancz Ltd", + "Viking Press", + "Vintage Books", + "Vintage Books at Random House", + "Virago Press", + "Virgin Publishing", + "Voyager Books", + "Brill", + "Allen Ltd", + "Zed Books", + "Ziff Davis Media", + "Zondervan"}; + +const std::array bookSeries = { + "Harry Potter", + "The Lord of the Rings", + "Game of Thrones", + "Sherlock Holmes", + "Percy Jackson", + "The Hunger Games", + "The Chronicles of Narnia", + "Dune", + "The Maze Runner", + "The Wheel of Time", + "A Song of Ice and Fire", + "Discworld", + "The Dark Tower", + "The Hitchhiker's Guide to the Galaxy", + "The Foundation Series", + "His Dark Materials", + "Outlander", + "The Inheritance Cycle", + "The Dresden Files", +}; + +const std::array titles = { + "Romeo and Juliet", + "Moby Dick", + "A Room with a View", + "Middlemarch", + "Little Women", + "The Complete Works of William Shakespeare", + "The Blue Castle", + "The Enchanted April", + "The Adventures of Ferdinand Count Fathom", + "Cranford", + "The Expedition of Humphry Clinker", + "The Adventures of Roderick Random", + "History of Tom Jones, a Foundling", + "Twenty Years After", + "My Life", + "Pride and Prejudice", + "The grisly horror", + "Alice's Adventures in Wonderland", + "Frankenstein; Or, The Modern Prometheus", + "Dracula", + "The Picture of Dorian Gray", + "A Tale of Two Cities", + "The Adventures of Sherlock Holmes", + "Metamorphosis", + "The Great Gatsby", + "Dora", + "Ulysses", + "The Count of Monte Cristo, Illustrated", + "The Brothers Karamazov", + "War and Peace", + "Hitting the line", + "The Yellow Wallpaper", + "The slang dictionary", + "Crime and Punishment", + "The book of antelopes", + "Travels in Kordofan", + "Bunny Brown and his sister Sue on the rolling ocean", + "The Iliad", + "The Prince", + "Grimms' Fairy Tales", + "Great Expectations", + "The Romance of Lust", + "The Wonderful Wizard of Oz", + "Moby Multiple Language Lists of Common Words", + "The Kama Sutra of Vatsyayana", + "The trial of Sacco and Vanzetti", + "A Modest Proposal", + "Beyond Good and Evil", + "Tractatus Logico-Philosophicus", + "Anna Karenina", + "Thus Spake Zarathustra", + "Jane Eyre", + "Don Quixote", + "Anne of Green Gables", + "On the Duty of Civil Disobedience", + "Treasure Island", + "A Doll's House", + "The nugget finders", + "Meditations", + "The Works of Edgar Allan Poe", + "Demonology and Devil-lore", + "A Study in Scarlet", + "Winnie-the-Pooh", + "Second Treatise of Government", + "Adventures of Huckleberry Finn", + "The Adventures of Tom Sawyer", + "The Importance of Being Earnest: A Trivial Comedy for Serious People", + "Walden, and On The Duty Of Civil Disobedience", + "The Strange Case of Dr. Jekyll and Mr. Hyde", + "Wuthering Heights", + "The War of the Worlds", + "The Philippines a Century Hence", + "The Prophet", + "The Republic", + "Calculus Made Easy", + "Little Women", + "Ruth Fielding in Alaska", + "The Rámáyan of Válmíki", + "The adventures of Uncle Wiggily the bunny rabbit gentleman with the twinkling pink nose", + "The divine comedy", + "Peter Pan", + "The King in Yellow", + "The Odyssey", + "Les Misérables", + "The Scarlet Letter", + "The Time Machine", + "Emma", + "A reference hand-book for nurses", + "The Problems of Philosophy", + "Carmilla", + "Dao De Jing: A Minimalist Translation", + "Notes from the Underground ", + "Through the Looking-Glass", + "My Bondage and My Freedom", + "Essays of Michel de Montaigne", + "The Magazine of History", + "Josefine Mutzenbacher", + "Heart of Darkness", + "David Copperfield", + "Three Men in a Boat (To Say Nothing of the Dog)"}; + +const std::array translators = { + "Gregory Rabassa", "Edith Grossman", "Charlotte Mandell", "David Bellos", "Ann Goldstein", + "C.K. Scott Moncrieff", "Lydia Davis", "Richard Howard", "Elliott Colla", "Katherine Silver", + "Ros Schwartz", "Jennifer Croft", "Michael Hofmann", "Maureen Freely", "Natasha Wimmer", +}; +} diff --git a/src/modules/book/BookData.h b/src/modules/book/BookData.h new file mode 100644 index 000000000..ab5304970 --- /dev/null +++ b/src/modules/book/BookData.h @@ -0,0 +1,15 @@ +#pragma once + +#include +#include + +namespace faker +{ +extern const std::array authors; +extern const std::array bookFormats; +extern const std::array genres; +extern const std::array publishers; +extern const std::array bookSeries; +extern const std::array titles; +extern const std::array translators; +} diff --git a/src/modules/book/data/Authors.h b/src/modules/book/data/Authors.h deleted file mode 100644 index 18111091d..000000000 --- a/src/modules/book/data/Authors.h +++ /dev/null @@ -1,108 +0,0 @@ -#pragma once - -#include -#include - -namespace faker -{ -const std::vector authors = {"Shakespeare, William", - "Smollett, T. (Tobias)", - "Dumas, Alexandre", - "Montgomery, L. M. (Lucy Maud)", - "Melville, Herman", - "Alcott, Louisa May", - "Eliot, George", - "Forster, E. M. (Edward Morgan)", - "Austen, Jane", - "Merrill, Frank T.", - "Dickens, Charles", - "Gaskell, Elizabeth Cleghorn", - "Von Arnim, Elizabeth", - "Brock, C. E. (Charles Edmund)", - "Fielding, Henry", - "Wagner, Richard", - "Twain, Mark", - "Doyle, Arthur Conan", - "Dostoyevsky, Fyodor", - "Packard, Vance", - "Adams, Clifford R. (Clifford Rose)", - "Wilde, Oscar", - "Garnett, Constance", - "Carroll, Lewis", - "Nietzsche, Friedrich Wilhelm", - "Tolstoy, Leo", - "Stevenson, Robert Louis", - "Wells, H. G. (Herbert George)", - "Shelley, Mary Wollstonecraft", - "Howard, Robert E. (Robert Ervin)", - "Baum, L. Frank (Lyman Frank)", - "Chesterton, G. K. (Gilbert Keith)", - "Homer", - "Plato", - "Rizal, José", - "Christie, Agatha", - "Joyce, James", - "Jowett, Benjamin", - "Poe, Edgar Allan", - "Verne, Jules", - "Thoreau, Henry David", - "Kafka, Franz", - "Stoker, Bram", - "Kipling, Rudyard", - "Doré, Gustave", - "Widger, David", - "Fitzgerald, F. Scott (Francis Scott)", - "Russell, Bertrand", - "Swift, Jonathan", - "Dante Alighieri", - "Wyllie, David", - "Hugo, Victor", - "Lang, Andrew", - "Maude, Aylmer", - "Burton, Richard Francis, Sir", - "Maude, Louise", - "Hawthorne, Nathaniel", - "Conrad, Joseph", - "London, Jack", - "Goethe, Johann Wolfgang von", - "James, Henry", - "Scott, Walter", - "Chekhov, Anton Pavlovich", - "Pope, Alexander", - "Ibsen, Henrik", - "Cervantes Saavedra, Miguel de", - "Balzac, Honoré de", - "Grimm, Jacob", - "Grimm, Wilhelm", - "Lovecraft, H. P. (Howard Phillips)", - "Burroughs, Edgar Rice", - "Shaw, Bernard", - "Gilman, Charlotte Perkins", - "Wodehouse, P. G. (Pelham Grenville)", - "Hotten, John Camden", - "Morley, Henry", - "Machiavelli, Niccolò", - "Derbyshire, Charles E.", - "Barrie, J. M. (James Matthew)", - "Brontë, Charlotte", - "Defoe, Daniel", - "Ward, Grady", - "Levy, Oscar", - "Burnett, Frances Hodgson", - "Schopenhauer, Arthur", - "Buckley, Theodore Alois", - "Milne, A. A. (Alan Alexander)", - "Marriott, W. K. (William Kenaz)", - "Vatsyayana", - "Potter, Beatrix", - "Ormsby, John", - "Bhide, Shivaram Parashuram", - "Butler, Samuel", - "Indrajit, Bhagavanlal", - "Maupassant, Guy de", - "Hapgood, Isabel Florence", - "Chambers, Robert W. (Robert William)", - "Marx, Karl", - "Eliot, T. S. (Thomas Stearns)", - "Hardy, Thomas"}; -} diff --git a/src/modules/book/data/BookFormat.h b/src/modules/book/data/BookFormat.h deleted file mode 100644 index a06332ae8..000000000 --- a/src/modules/book/data/BookFormat.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include -#include - -namespace faker -{ -const std::vector bookFormats{ - "Paperback", - "Hardcover", - "Kindle", -}; -} diff --git a/src/modules/book/data/Genres.h b/src/modules/book/data/Genres.h deleted file mode 100644 index 2806aebf1..000000000 --- a/src/modules/book/data/Genres.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include -#include - -namespace faker -{ -const std::vector genres = {"Adventure stories", - "Classics", - "Crime", - "Fairy tales, fables, and folk tales", - "Fantasy", - "Historical fiction", - "Horror", - "Humour and satire", - "Literary fiction", - "Mystery", - "Poetry", - "Plays", - "Romance", - "Science fiction", - "Short stories", - "Thrillers", - "War", - "Women’s fiction", - "Young adult", - "Non-fiction", - "Autobiography and memoir", - "Biography", - "Essays", - "Non-fiction novel", - "Self-help"}; -} diff --git a/src/modules/book/data/Publishers.h b/src/modules/book/data/Publishers.h deleted file mode 100644 index 82198a4d8..000000000 --- a/src/modules/book/data/Publishers.h +++ /dev/null @@ -1,271 +0,0 @@ -#pragma once - -#include -#include - -namespace faker -{ -const std::vector publishers = {"Academic Press", - "Ace Books", - "Addison-Wesley", - "Adis International", - "Airiti Press", - "Andrews McMeel Publishing", - "Anova Books", - "Anvil Press Poetry", - "Applewood Books", - "Apress", - "Athabasca University Press", - "Atheneum Books", - "Atheneum Publishers", - "Atlantic Books", - "Atlas Press", - "Ballantine Books", - "Banner of Truth Trust", - "Bantam Books", - "Bantam Spectra", - "Barrie & Jenkins", - "Basic Books", - "BBC Books", - "Harvard University Press", - "Belknap Press", - "Bella Books", - "Bellevue Literary Press", - "Berg Publishers", - "Berkley Books", - "Bison Books", - "Black Dog Publishing", - "Black Library", - "Black Sparrow Books", - "Blackie and Son Limited", - "Blackstaff Press", - "Blackwell Publishing", - "John Blake Publishing", - "Bloodaxe Books", - "Bloomsbury Publishing Plc", - "Blue Ribbon Books", - "Book League of America", - "Book Works", - "Booktrope", - "Borgo Press", - "Bowes & Bowes", - "Boydell & Brewer", - "Breslov Research Institute", - "Brill Publishers", - "Brimstone Press", - "Broadview Press", - "Burns & Oates", - "Butterworth-Heinemann", - "Caister Academic Press", - "Cambridge University Press", - "Candlewick Press", - "Canongate Books", - "Carcanet Press", - "Carlton Books", - "Carlton Publishing Group", - "Carnegie Mellon University Press", - "Casemate Publishers", - "Cengage Learning", - "Central European University Press", - "Chambers Harrap", - "Charles Scribner's Sons", - "Chatto and Windus", - "Chick Publications", - "Chronicle Books", - "Churchill Livingstone", - "Cisco Press", - "City Lights Publishers", - "Cloverdale Corporation", - "D. Appleton & Company", - "D. Reidel", - "Da Capo Press", - "Daedalus Publishing", - "Dalkey Archive Press", - "Darakwon Press", - "David & Charles", - "DAW Books", - "Dedalus Books", - "Del Rey Books", - "E. P. Dutton", - "Earthscan", - "ECW Press", - "Eel Pie Publishing", - "Eerdmans Publishing", - "Edupedia Publications", - "Ellora's Cave", - "Elsevier", - "Emerald Group Publishing", - "Etruscan Press", - "Faber and Faber", - "FabJob", - "Fairview Press", - "Farrar, Straus & Giroux", - "Fearless Books", - "Felony & Mayhem Press", - "Firebrand Books", - "Flame Tree Publishing", - "Focal Press", - "G. P. Putnam's Sons", - "G-Unit Books", - "Gaspereau Press", - "Gay Men's Press", - "Gefen Publishing House", - "George H. Doran Company", - "George Newnes", - "George Routledge & Sons", - "Godwit Press", - "Golden Cockerel Press", - "Hachette Book Group USA", - "Hackett Publishing Company", - "Hamish Hamilton", - "Happy House", - "Harcourt Assessment", - "Harcourt Trade Publishers", - "Harlequin Enterprises Ltd", - "Harper & Brothers", - "Harper & Row", - "HarperCollins", - "HarperPrism", - "HarperTrophy", - "Harry N. Abrams, Inc.", - "Harvard University Press", - "Harvest House", - "Harvill Press at Random House", - "Hawthorne Books", - "Hay House", - "Haynes Manuals", - "Heyday Books", - "HMSO", - "Hodder & Stoughton", - "Hodder Headline", - "Hogarth Press", - "Holland Park Press", - "Holt McDougal", - "Horizon Scientific Press", - "Ian Allan Publishing", - "Ignatius Press", - "Imperial War Museum", - "Indiana University Press", - "J. M. Dent", - "Jaico Publishing House", - "Jarrolds Publishing", - "Karadi Tales", - "Kensington Books", - "Kessinger Publishing", - "Kodansha", - "Kogan Page", - "Koren Publishers Jerusalem", - "Ladybird Books", - "Leaf Books", - "Leafwood Publishers", - "Left Book Club", - "Legend Books", - "Lethe Press", - "Libertas Academica", - "Liberty Fund", - "Library of America", - "Lion Hudson", - "Macmillan Publishers", - "Mainstream Publishing", - "Manchester University Press", - "Mandrake of Oxford", - "Mandrake Press", - "Manning Publications", - "Manor House Publishing", - "Mapin Publishing", - "Marion Boyars Publishers", - "Mark Batty Publisher", - "Marshall Cavendish", - "Marshall Pickering", - "Martinus Nijhoff Publishers", - "Mascot Books", - "Matthias Media", - "McClelland and Stewart", - "McFarland & Company", - "McGraw-Hill Education", - "McGraw Hill Financial", - "Medknow Publications", - "Naiad Press", - "Nauka", - "NavPress", - "New Directions Publishing", - "New English Library", - "New Holland Publishers", - "New Village Press", - "Newnes", - "No Starch Press", - "Nonesuch Press", - "Oberon Books", - "Open Court Publishing Company", - "Open University Press", - "Orchard Books", - "O'Reilly Media", - "Orion Books", - "Packt Publishing", - "Palgrave Macmillan", - "Pan Books", - "Pantheon Books at Random House", - "Papadakis Publisher", - "Parachute Publishing", - "Parragon", - "Pathfinder Press", - "Paulist Press", - "Pavilion Books", - "Peace Hill Press", - "Pecan Grove Press", - "Pen and Sword Books", - "Penguin Books", - "Random House", - "Reed Elsevier", - "Reed Publishing", - "SAGE Publications", - "St. Martin's Press", - "Salt Publishing", - "Sams Publishing", - "Schocken Books", - "Scholastic Press", - "Charles Scribner's Sons", - "Seagull Books", - "Secker & Warburg", - "Shambhala Publications", - "Shire Books", - "Shoemaker & Hoard Publishers", - "Shuter & Shooter Publishers", - "Sidgwick & Jackson", - "Signet Books", - "Simon & Schuster", - "T & T Clark", - "Tachyon Publications", - "Tammi", - "Target Books", - "Tarpaulin Sky Press", - "Tartarus Press", - "Tate Publishing & Enterprises", - "Taunton Press", - "Taylor & Francis", - "Ten Speed Press", - "UCL Press", - "Unfinished Monument Press", - "United States Government Publishing Office", - "University of Akron Press", - "University of Alaska Press", - "University of California Press", - "University of Chicago Press", - "University of Michigan Press", - "University of Minnesota Press", - "University of Nebraska Press", - "Velazquez Press", - "Verso Books", - "Victor Gollancz Ltd", - "Viking Press", - "Vintage Books", - "Vintage Books at Random House", - "Virago Press", - "Virgin Publishing", - "Voyager Books", - "Brill", - "Allen Ltd", - "Zed Books", - "Ziff Davis Media", - "Zondervan"}; -} diff --git a/src/modules/book/data/Series.h b/src/modules/book/data/Series.h deleted file mode 100644 index f9b2177da..000000000 --- a/src/modules/book/data/Series.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include -#include - -namespace faker -{ -const std::vector bookSeries = { - "Harry Potter", - "The Lord of the Rings", - "Game of Thrones", - "Sherlock Holmes", - "Percy Jackson", - "The Hunger Games", - "The Chronicles of Narnia", - "Dune", - "The Maze Runner", - "The Wheel of Time", - "A Song of Ice and Fire", - "Discworld", - "The Dark Tower", - "The Hitchhiker's Guide to the Galaxy", - "The Foundation Series", - "His Dark Materials", - "Outlander", - "The Inheritance Cycle", - "The Dresden Files", -}; -} diff --git a/src/modules/book/data/Titles.h b/src/modules/book/data/Titles.h deleted file mode 100644 index 0ee3999b1..000000000 --- a/src/modules/book/data/Titles.h +++ /dev/null @@ -1,109 +0,0 @@ -#pragma once - -#include -#include - -namespace faker -{ -const std::vector titles = { - "Romeo and Juliet", - "Moby Dick", - "A Room with a View", - "Middlemarch", - "Little Women", - "The Complete Works of William Shakespeare", - "The Blue Castle", - "The Enchanted April", - "The Adventures of Ferdinand Count Fathom", - "Cranford", - "The Expedition of Humphry Clinker", - "The Adventures of Roderick Random", - "History of Tom Jones, a Foundling", - "Twenty Years After", - "My Life", - "Pride and Prejudice", - "The grisly horror", - "Alice's Adventures in Wonderland", - "Frankenstein; Or, The Modern Prometheus", - "Dracula", - "The Picture of Dorian Gray", - "A Tale of Two Cities", - "The Adventures of Sherlock Holmes", - "Metamorphosis", - "The Great Gatsby", - "Dora", - "Ulysses", - "The Count of Monte Cristo, Illustrated", - "The Brothers Karamazov", - "War and Peace", - "Hitting the line", - "The Yellow Wallpaper", - "The slang dictionary", - "Crime and Punishment", - "The book of antelopes", - "Travels in Kordofan", - "Bunny Brown and his sister Sue on the rolling ocean", - "The Iliad", - "The Prince", - "Grimms' Fairy Tales", - "Great Expectations", - "The Romance of Lust", - "The Wonderful Wizard of Oz", - "Moby Multiple Language Lists of Common Words", - "The Kama Sutra of Vatsyayana", - "The trial of Sacco and Vanzetti", - "A Modest Proposal", - "Beyond Good and Evil", - "Tractatus Logico-Philosophicus", - "Anna Karenina", - "Thus Spake Zarathustra", - "Jane Eyre", - "Don Quixote", - "Anne of Green Gables", - "On the Duty of Civil Disobedience", - "Treasure Island", - "A Doll's House", - "The nugget finders", - "Meditations", - "The Works of Edgar Allan Poe", - "Demonology and Devil-lore", - "A Study in Scarlet", - "Winnie-the-Pooh", - "Second Treatise of Government", - "Adventures of Huckleberry Finn", - "The Adventures of Tom Sawyer", - "The Importance of Being Earnest: A Trivial Comedy for Serious People", - "Walden, and On The Duty Of Civil Disobedience", - "The Strange Case of Dr. Jekyll and Mr. Hyde", - "Wuthering Heights", - "The War of the Worlds", - "The Philippines a Century Hence", - "The Prophet", - "The Republic", - "Calculus Made Easy", - "Little Women", - "Ruth Fielding in Alaska", - "The Rámáyan of Válmíki", - "The adventures of Uncle Wiggily the bunny rabbit gentleman with the twinkling pink nose", - "The divine comedy", - "Peter Pan", - "The King in Yellow", - "The Odyssey", - "Les Misérables", - "The Scarlet Letter", - "The Time Machine", - "Emma", - "A reference hand-book for nurses", - "The Problems of Philosophy", - "Carmilla", - "Dao De Jing: A Minimalist Translation", - "Notes from the Underground ", - "Through the Looking-Glass", - "My Bondage and My Freedom", - "Essays of Michel de Montaigne", - "The Magazine of History", - "Josefine Mutzenbacher", - "Heart of Darkness", - "David Copperfield", - "Three Men in a Boat (To Say Nothing of the Dog)"}; -} diff --git a/src/modules/book/data/Translators.h b/src/modules/book/data/Translators.h deleted file mode 100644 index 499a33fdf..000000000 --- a/src/modules/book/data/Translators.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include -#include - -namespace faker -{ -const std::vector translators = { - "Gregory Rabassa", "Edith Grossman", "Charlotte Mandell", "David Bellos", "Ann Goldstein", - "C.K. Scott Moncrieff", "Lydia Davis", "Richard Howard", "Elliott Colla", "Katherine Silver", - "Ros Schwartz", "Jennifer Croft", "Michael Hofmann", "Maureen Freely", "Natasha Wimmer", -}; -} diff --git a/tests/modules/book/BookTest.cpp b/tests/modules/book/BookTest.cpp index 69593a005..1bfe76649 100644 --- a/tests/modules/book/BookTest.cpp +++ b/tests/modules/book/BookTest.cpp @@ -4,14 +4,8 @@ #include "gtest/gtest.h" +#include "book/BookData.h" #include "common/StringHelper.h" -#include "book/data/Authors.h" -#include "book/data/BookFormat.h" -#include "book/data/Genres.h" -#include "book/data/Publishers.h" -#include "book/data/Series.h" -#include "book/data/Titles.h" -#include "book/data/Translators.h" using namespace ::testing; using namespace faker; @@ -25,28 +19,29 @@ TEST_F(BookTest, shouldGenerateTitle) { const auto bookTitle = Book::title(); - ASSERT_TRUE(std::ranges::any_of(titles, [bookTitle](const std::string& title) { return title == bookTitle; })); + ASSERT_TRUE(std::ranges::any_of(titles, [bookTitle](const std::string_view& title) { return title == bookTitle; })); } TEST_F(BookTest, shouldGenerateGenre) { const auto bookGenre = Book::genre(); - ASSERT_TRUE(std::ranges::any_of(genres, [bookGenre](const std::string& genre) { return genre == bookGenre; })); + ASSERT_TRUE(std::ranges::any_of(genres, [bookGenre](const std::string_view& genre) { return genre == bookGenre; })); } TEST_F(BookTest, shouldGenerateAuthor) { const auto bookAuthor = Book::author(); - ASSERT_TRUE(std::ranges::any_of(authors, [bookAuthor](const std::string& author) { return author == bookAuthor; })); + ASSERT_TRUE( + std::ranges::any_of(authors, [bookAuthor](const std::string_view& author) { return author == bookAuthor; })); } TEST_F(BookTest, shouldGeneratePublisher) { const auto bookPublisher = Book::publisher(); - ASSERT_TRUE(std::ranges::any_of(publishers, [bookPublisher](const std::string& publisher) + ASSERT_TRUE(std::ranges::any_of(publishers, [bookPublisher](const std::string_view& publisher) { return publisher == bookPublisher; })); } @@ -64,18 +59,11 @@ TEST_F(BookTest, shouldGenerateIsbn) ASSERT_EQ(isbnNumbersGroups[4].size(), 1); } -TEST_F(BookTest, shouldGenerateReleaseYear) -{ - const auto releaseYear = Book::releaseYear(); - - ASSERT_TRUE((releaseYear >= 1940) && (releaseYear <= 2024)); -} - TEST_F(BookTest, shouldGenerateTranslator) { const auto bookTranslator = Book::translator(); - ASSERT_TRUE(std::ranges::any_of(translators, [bookTranslator](const std::string& translator) + ASSERT_TRUE(std::ranges::any_of(translators, [bookTranslator](const std::string_view& translator) { return translator == bookTranslator; })); } @@ -83,21 +71,14 @@ TEST_F(BookTest, shouldGenerateFormat) { const auto bookFormat = Book::format(); - ASSERT_TRUE( - std::ranges::any_of(bookFormats, [bookFormat](const std::string& format) { return format == bookFormat; })); -} - -TEST_F(BookTest, shouldGeneratePage) -{ - const auto bookPage = Book::page(); - - ASSERT_TRUE(bookPage >= 50 && bookPage <= 999); + ASSERT_TRUE(std::ranges::any_of(bookFormats, + [bookFormat](const std::string_view& format) { return format == bookFormat; })); } TEST_F(BookTest, shouldGenerateSeries) { const auto randomSeries = Book::series(); - ASSERT_TRUE( - std::ranges::any_of(bookSeries, [randomSeries](const std::string& series) { return series == randomSeries; })); + ASSERT_TRUE(std::ranges::any_of(bookSeries, + [randomSeries](const std::string_view& series) { return series == randomSeries; })); }