diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b419476a..d496c49aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,27 @@ All notable changes to this project will be documented in this file ### ⚠ BREAKING CHANGES -* removed `Structure` module +* removed `structure` module +* removed `book.translator` method, use `person.fullName` instead +* removed `book.isbn` method, use `commerce.isbn` instead +* removed `commerce.price` method, use `finance.amount` instead +* removed `commerce.productId` method, use `string.alphanumeric` instead +* removed `commerce.productRating` method, use `number.decimal` instead +* removed `commerce.discountAmount` method, use `number.decimal` instead +* removed `commerce.discountPercentage` method, use `number.decimal` instead +* removed `commerce.orderNumber` method, use `string.numeric` instead +* removed `commerce.discountCode` method, use `string.alphanumeric` instead +* removed `git.author` method, use `person.fullName` instead +* removed `helper.shuffle` method, use standard library shuffle instead +* removed `person.middleName` method, use `person.firstName` instead +* removed `weather.temperature` method, use `number.decimal` instead +* removed `weather.pressure` method, use `number.decimal` instead +* removed `weather.visibility` method, use `number.decimal` instead +* removed `weather.windSpeed` method, use `number.decimal` instead +* removed `weather.uvIndex` method, use `number.integer` instead +* removed `weather.humidity` method, use `number.integer` instead +* removed `weather.cloudCover` method, use `number.integer` instead + * changed std::string to std::string_view in where possible ### Features diff --git a/include/faker-cxx/Book.h b/include/faker-cxx/Book.h index ff4535fcf..0bf7eab8f 100644 --- a/include/faker-cxx/Book.h +++ b/include/faker-cxx/Book.h @@ -51,28 +51,6 @@ class Book */ static std::string_view publisher(); - /** - * @brief Returns a random book ISBN. - * - * @returns Book ISBN. - * - * @code - * Book::isbn() // "978-83-01-00000-1" - * @endcode - */ - static std::string isbn(); - - /** - * @brief Returns the full name of a translator - * - * @returns std::string_view full name - * - * @code - * Book::translator() // "Eric Floyd" - * @endcode - */ - static std::string_view translator(); - /** * @brief Returns format of book * diff --git a/include/faker-cxx/Commerce.h b/include/faker-cxx/Commerce.h index 2457bce37..741beed40 100644 --- a/include/faker-cxx/Commerce.h +++ b/include/faker-cxx/Commerce.h @@ -18,18 +18,6 @@ class Commerce */ static std::string_view department(); - /** - * @brief Generates a random price between the given bounds (inclusive). - - * @param min The lower bound for the price. Defaults to `0`. - * @param max The upper bound for the price. Defaults to `1000`. - * - * @code - * Commerce::price() // "88.62" - * @endcode - */ - static std::string price(double min = 0, double max = 1000); - /** * @brief Generates a random sku by default only with digits. * @@ -130,17 +118,6 @@ class Commerce */ static std::string ISBN10(); - /** - * @brief Returns a random product ID. - * - * @returns productId. - * - * @code - * Commerce::productId() // "ABCD123456" - * @endcode - */ - static std::string productId(); - /** * @brief Returns a random payment type. * @@ -196,17 +173,6 @@ class Commerce */ static std::string_view productReview(); - /** - * @brief Returns a random product rating (0-5). - * - * @returns productRating. - * - * @code - * Commerce::productRating() // 4.1 - * @endcode - */ - static double productRating(); - /** * @brief Returns a random discount type. * @@ -218,50 +184,6 @@ class Commerce */ static std::string_view discountType(); - /** - * @brief Returns random discount code within the specified range of 6 to 12 characters. - * - * @returns discount code consists of uppercase letters and numbers. - * - * @code - * Commerce::discountCode() // "VNM15DEC1" - * @endcode - */ - static std::string discountCode(); - - /** - * @brief Returns a random discount amount within the specified range of 10 to 1000. - * - * @returns discountAmount. - * - * @code - * Commerce::discountAmount() // 57.80 - * @endcode - */ - static double discountAmount(); - - /** - * @brief Returns a random discount percentage within the specified range of 1. to 90. - * - * @returns discountPercentage. - * - * @code - * Commerce::discountPercentage() // 35.50 - * @endcode - */ - static double discountPercentage(); - - /** - * @brief Returns a random order number. - * - * @returns orderNumber. - * - * @code - * Commerce::orderNumber() // 0123456 - * @endcode - */ - static std::string orderNumber(); - /** * @brief Returns a random order status. * diff --git a/include/faker-cxx/Git.h b/include/faker-cxx/Git.h index f8ff6b2aa..9371073ed 100644 --- a/include/faker-cxx/Git.h +++ b/include/faker-cxx/Git.h @@ -84,18 +84,5 @@ class Git * @endcode */ static std::string commitSha(unsigned length = 40); - - /** - * @brief Returns a random author name and email. - * - * @param - * - * @returns Author. - * - * @code - * Git::author // {Author.name = "Rachel McLaughlin", Author.email = "Rachel_McLaughlin@gmail.com"} - * @endcode - */ - static Author author(); }; } diff --git a/include/faker-cxx/Helper.h b/include/faker-cxx/Helper.h index ca6b744e9..f9216ce7f 100644 --- a/include/faker-cxx/Helper.h +++ b/include/faker-cxx/Helper.h @@ -61,12 +61,14 @@ class Helper static auto arrayElement(It start, It end) -> decltype(*::std::declval()) { size_t size = end - start; + if (size == 0) { throw std::invalid_argument{"Range [start,end) is empty."}; } - const auto index = Number::integer(size - 1); + const std::integral auto index = Number::integer(size - 1); + return start[index]; } @@ -145,7 +147,9 @@ class Helper } T item; + std::sample(data.begin(), data.end(), &item, 1, pseudoRandomGenerator); + return item; } @@ -188,41 +192,26 @@ class Helper } const std::integral auto targetWeightValue = Number::integer(1, sumOfWeights); + unsigned currentSum = 0; + size_t currentIdx = 0; while (currentIdx < data.size()) { currentSum += data[currentIdx].weight; + if (currentSum >= targetWeightValue) + { break; + } + currentIdx++; } return data.at(currentIdx).value; } - /** - * @brief Returns shuffled vector. - * - * @tparam T an element type of the vector. - * - * @param data The vector. - * - * @return Vector with shuffled elements. - * - * @code - * Helper::shuffle(std::vector{{"hello"}, {"world"}}) // {{"world"}, {"hello"}} - * @endcode - */ - template - static std::vector shuffle(std::vector data) - { - std::shuffle(std::begin(data), std::end(data), pseudoRandomGenerator); - - return data; - } - /** * @brief Returns shuffled std::string * @@ -265,6 +254,7 @@ class Helper } std::vector keys; + for (const auto& entry : object) { keys.push_back(entry.first); @@ -296,6 +286,7 @@ class Helper { return callback(); } + return TResult(); } diff --git a/include/faker-cxx/Person.h b/include/faker-cxx/Person.h index 1655b0d6b..e1dbd7643 100644 --- a/include/faker-cxx/Person.h +++ b/include/faker-cxx/Person.h @@ -47,21 +47,6 @@ class Person static std::string_view lastName(std::optional country = std::nullopt, std::optional sex = std::nullopt); - /** - * @brief Returns a random middle name. - * - * @param country The local country. Defaults to `Country::England`. - * @param sex The optional sex to use. - * - * @returns Middle name starting with a capital letter. - * - * @code - * Person::middleName() // "Васильевич" - * @endcode - */ - static std::string_view middleName(std::optional country = std::nullopt, - std::optional sex = std::nullopt); - /** * @brief Returns a random full name. * diff --git a/include/faker-cxx/Weather.h b/include/faker-cxx/Weather.h index d2ad5efc0..8358c2884 100644 --- a/include/faker-cxx/Weather.h +++ b/include/faker-cxx/Weather.h @@ -7,95 +7,6 @@ namespace faker class Weather { public: - struct Temperature - { - double metric, imperial; - }; - - /** - * @brief Generates a random temperature - * - * @return Temperature object with metric and imperial temperatures - * - * @code - * Weather::temperature(); // Temperature.metric = 10, Temperature.imperial = 50 - * @endcode - */ - static Temperature temperature(); - - struct Pressure - { - double metric; - double imperial; - }; - - /** - * @brief Generated a random pressure - * - * @return Pressure object with metric and imperial pressures - * - * @code - * Weather::pressure(); // Pressure.metric = 1000, Pressure.imperial = 14.5 - * @endcode - */ - static Pressure pressure(); - - struct Visibility - { - double metric; - double imperial; - }; - - /** - * @brief Generated a random visibility - * - * @return Visibility object with metric and imperial visibility - * - * @code - * Weather::visibility(); // Visibility.metric = 10.0, Visibility.imperial = 6.2 - * @endcode - */ - static Visibility visibility(); - - struct WindSpeed - { - double metric; - double imperial; - }; - - /** - * @brief Generated a random wind speed - * - * @return WindSpeed object with metric and imperial wind speed - * - * @code - * Weather::windSpeed(); // WindSpeed.metric = 10.0, WindSpeed.imperial = 6.2 - * @endcode - */ - static WindSpeed windSpeed(); - - /** - * @brief Generated a random uvIndex - * - * @return Int A random uvIndex - * - * @code - * Weather::uvIndex(); // 10 - * @endcode - */ - static int uvIndex(); - - /** - * @brief Generated a random humidity percentage - * - * @return Int A random humidity percentage - * - * @code - * Weather::humidity(); // 10 - * @endcode - */ - static int humidity(); - /** * @brief Generated a random weather description * @@ -106,16 +17,5 @@ class Weather * @endcode */ static std::string_view weatherDescription(); - - /** - * @brief Generated a random cloud cover percentage - * - * @return Int A random cloud cover percentage - * - * @code - * Weather::cloudCover(); // 10 - * @endcode - */ - static int cloudCover(); }; } diff --git a/src/modules/book/Book.cpp b/src/modules/book/Book.cpp index decd7b75a..470dac808 100644 --- a/src/modules/book/Book.cpp +++ b/src/modules/book/Book.cpp @@ -1,12 +1,9 @@ #include "faker-cxx/Book.h" -#include #include -#include "../../common/FormatHelper.h" #include "BookData.h" #include "faker-cxx/Helper.h" -#include "faker-cxx/String.h" namespace faker { @@ -30,17 +27,6 @@ std::string_view Book::publisher() return Helper::arrayElement(publishers); } -std::string Book::isbn() -{ - return FormatHelper::format("{}-{}-{}-{}-{}", String::numeric(3, false), String::numeric(2), String::numeric(2), - String::numeric(5), String::numeric(1)); -} - -std::string_view Book::translator() -{ - return Helper::arrayElement(translators); -} - std::string_view Book::format() { return Helper::arrayElement(bookFormats); diff --git a/src/modules/book/BookData.cpp b/src/modules/book/BookData.cpp index d6ef1fa12..f9c9032de 100644 --- a/src/modules/book/BookData.cpp +++ b/src/modules/book/BookData.cpp @@ -5,530 +5,557 @@ 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 authors = { + "A. A. Milne", + "Agatha Christie", + "Alexander Pope", + "Alexandre Dumas", + "Alice Walker", + "Andrew Lang", + "Anton Pavlovich Chekhov", + "Arthur Conan Doyle", + "Arthur Schopenhauer", + "Aylmer Maude", + "Beatrix Potter", + "Benjamin Jowett", + "Bernard Shaw", + "Bertrand Russell", + "Bhagavanlal Indrajit", + "Bram Stoker", + "Brian Evenson", + "C. E. Brock", + "Charles Dickens", + "Charles E. Derbyshire", + "Charlotte Brontë", + "Charlotte Perkins Gilman", + "Clifford R. Adams", + "Constance Garnett", + "Dan Brown", + "Daniel Defoe", + "Dante Alighieri", + "David Widger", + "David Wyllie", + "Dean Koontz", + "E. M. Forster", + "Edgar Allan Poe", + "Edgar Rice Burroughs", + "Elizabeth Cleghorn Gaskell", + "Elizabeth Von Arnim", + "F. Scott Fitzgerald", + "Frances Hodgson Burnett", + "Frank T. Merrill", + "Franz Kafka", + "Friedrich Wilhelm Nietzsche", + "Fyodor Dostoyevsky", + "G. K. Chesterton", + "George Eliot", + "George R. R. Martin", + "George Saunders", + "Grady Ward", + "Gustave Doré", + "Guy de Maupassant", + "H. G. Wells", + "H. P. Lovecraft", + "Haruki Murakami", + "Henrik Ibsen", + "Henry David Thoreau", + "Henry Fielding", + "Henry James", + "Henry Morley", + "Herman Melville", + "Homer", + "Honoré de Balzac", + "Ian McEwan", + "Isabel Florence Hapgood", + "J. K. Rowling", + "J. M. Barrie", + "Jack London", + "Jacob Grimm", + "Jacqueline Crooks", + "James Joyce", + "James Patterson", + "Jane Austen", + "Johann Wolfgang von Goethe", + "John Camden Hotten", + "John Green", + "John Grisham", + "John Ormsby", + "Jonathan Franzen", + "Jonathan Swift", + "Joseph Conrad", + "José Rizal", + "Jules Verne", + "Karl Marx", + "Kazuo Ishiguro", + "Khaled Hosseini", + "L. Frank Baum", + "L. M. Montgomery", + "Leo Tolstoy", + "Lewis Carroll", + "Louisa May Alcott", + "Louise Maude", + "Margaret Atwood", + "Mark Twain", + "Mary Wollstonecraft Shelley", + "Michael Chabon", + "Miguel de Cervantes Saavedra", + "Nathaniel Hawthorne", + "Neil Gaiman", + "Niccolò Machiavelli", + "Oscar Levy", + "Oscar Wilde", + "P. G. Wodehouse", + "Plato", + "R. L. Stine", + "Rachel Kushner", + "Richard Wagner", + "Robert E. Howard", + "Robert Louis Stevenson", + "Robert W. Chambers", + "Rudyard Kipling", + "Samuel Butler", + "Shivaram Parashuram Bhide", + "Sir Richard Francis Burton", + "Stephen King", + "Suzanne Collins", + "T. S. Eliot", + "T. Smollett", + "Theodore Alois Buckley", + "Thomas Hardy", + "Toni Morrison", + "Vance Packard", + "Vatsyayana", + "Victor Hugo", + "W. K. Marriott", + "Walter Scott", + "Wilhelm Grimm", + "William Shakespeare", + "Zadie Smith", +}; -const std::array bookFormats{ +const std::array bookFormats{ "Paperback", "Hardcover", - "Kindle", + "Ebook", + "Audiobook", }; -const std::array bookGenres = {"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 bookGenres = { + "Adventure", "Biography", "Business", "Children Literature", + "Classic", "Comedy", "Comic", "Detective", + "Drama", "Fantasy", "Graphic Novel", "Historical Fiction", + "Horror", "Memoir", "Mystery", "Mythology", + "Philosophy", "Poetry", "Psychology", "Religion", + "Romance", "Science Fiction", "Thriller", "Western", + "Young Adult", +}; -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 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 = { +const std::array bookSeries = { + "A Song of Ice and Fire", + "Anna Karenina", + "Colonel Race", + "Discworld", + "Dune", "Harry Potter", - "The Lord of the Rings", - "Game of Thrones", - "Sherlock Holmes", + "Hercule Poirot", + "His Dark Materials", + "Jane Austen Murder Mysteries", + "Little Women", + "Outlander", "Percy Jackson", - "The Hunger Games", + "Sherlock Holmes", + "The Arc of a Scythe", + "The Bartimaeus Trilogy", + "The Border Trilogy", "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 Dresden Files", + "The Eighth Life", "The Foundation Series", - "His Dark Materials", - "Outlander", + "The Hitchhiker's Guide to the Galaxy", + "The Hunger Games", + "The Infinity Cycle", "The Inheritance Cycle", - "The Dresden Files", + "The Lord of the Rings", + "The Maze Runner", + "The Prison Healer", + "The Red Rising Saga", + "The Southern Reach", + "The Wheel of Time", + "Thursday Next Series", + "Twilight", + "War and Peace", }; -const std::array titles = { - "Romeo and Juliet", - "Moby Dick", +const std::array titles = { + "A Brief History of Time", + "A Clockwork Orange", + "A Doll's House", + "A Modest Proposal", "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 Study in Scarlet", "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", + "Adventures of Huckleberry Finn", + "Alice's Adventures in Wonderland", + "Anna Karenina", + "Anne of Green Gables", + "Beloved", + "Beyond Good and Evil", + "Bible", + "Brave New World", + "Carmilla", + "Catch-22", + "Cranford", "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", + "Dao De Jing: A Minimalist Translation", + "David Copperfield", + "Don Quixote", + "Dora", + "Dracula", + "Emma", + "Faust", + "For Whom the Bell Tolls", + "Frankenstein", + "Freakonomics", "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", + "Grimms' Fairy Tales", + "Hamlet", + "Heart of Darkness", + "Hitting the line", + "In Search of Lost Time", + "Invisible Man", "Jane Eyre", - "Don Quixote", - "Anne of Green Gables", - "On the Duty of Civil Disobedience", - "Treasure Island", - "A Doll's House", - "The nugget finders", + "Josefine Mutzenbacher", + "Les Misérables", + "Life of Pi", + "Little Women", + "Lolita", + "Long Walk to Freedom", + "Madame Bovary", "Meditations", - "The Works of Edgar Allan Poe", - "Demonology and Devil-lore", - "A Study in Scarlet", - "Winnie-the-Pooh", + "Metamorphosis", + "Middlemarch", + "Moby Dick", + "Mrs. Dalloway", + "My Bondage and My Freedom", + "My Life", + "Nineteen Eighty Four", + "Notes from the Underground ", + "On the Duty of Civil Disobedience", + "On the Road", + "One Hundred Years of Solitude", + "Peter Pan", + "Pride and Prejudice", + "Robinson Crusoe", + "Romeo and Juliet", + "Ruth Fielding in Alaska", "Second Treatise of Government", - "Adventures of Huckleberry Finn", + "The Adventures of Sherlock Holmes", "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 Art of War", + "The Blue Castle", + "The Brothers Karamazov", + "The Catcher in the Rye", + "The Count of Monte Cristo", + "The Diary of a Young Girl", + "The Divine Comedy", + "The Enchanted April", + "The Grapes of Wrath", + "The Great Gatsby", + "The Handmaid’s Tale", + "The Iliad", "The King in Yellow", + "The Kite Runner", + "The Little Prince", + "The Magic Mountain", "The Odyssey", - "Les Misérables", + "The Old Man and the Sea", + "The Picture of Dorian Gray", + "The Prince", + "The Problems of Philosophy", + "The Prophet", + "The Republic", "The Scarlet Letter", + "The Sound and the Fury", + "The Stranger", + "The Sun Also Rises", "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", + "The Trial", + "The War of the Worlds", + "The Wonderful Wizard of Oz", + "The Works of Edgar Allan Poe", + "The Yellow Wallpaper", + "To Kill a Mockingbird", + "Ulysses", + "War and Peace", + "Winnie-the-Pooh", + "Wuthering Heights", }; + } diff --git a/src/modules/book/BookData.h b/src/modules/book/BookData.h index 4982ee268..7aff3c8b6 100644 --- a/src/modules/book/BookData.h +++ b/src/modules/book/BookData.h @@ -5,11 +5,10 @@ namespace faker { -extern const std::array authors; -extern const std::array bookFormats; +extern const std::array authors; +extern const std::array bookFormats; extern const std::array bookGenres; extern const std::array publishers; -extern const std::array bookSeries; -extern const std::array titles; -extern const std::array translators; +extern const std::array bookSeries; +extern const std::array titles; } diff --git a/src/modules/commerce/Commerce.cpp b/src/modules/commerce/Commerce.cpp index c650e856d..cea2e7f82 100644 --- a/src/modules/commerce/Commerce.cpp +++ b/src/modules/commerce/Commerce.cpp @@ -1,15 +1,11 @@ #include "faker-cxx/Commerce.h" -#include -#include #include #include #include "../../common/FormatHelper.h" #include "CommerceData.h" -#include "faker-cxx/Finance.h" #include "faker-cxx/Helper.h" -#include "faker-cxx/Number.h" #include "faker-cxx/String.h" namespace faker @@ -19,11 +15,6 @@ std::string_view Commerce::department() return Helper::arrayElement(departments); } -std::string Commerce::price(double min, double max) -{ - return Finance::amount(min, max); -} - std::string Commerce::sku(unsigned int length) { return String::numeric(length, false); @@ -160,11 +151,6 @@ std::string Commerce::ISBN10() return isbn10 + std::to_string(checkDigit); } -std::string Commerce::productId() -{ - return String::alphanumeric(10, StringCasing::Upper, ""); -} - std::string_view Commerce::paymentType() { return Helper::arrayElement(paymentTypes); @@ -190,44 +176,11 @@ std::string_view Commerce::productReview() return Helper::arrayElement(productReviews); } -double Commerce::productRating() -{ - const std::floating_point auto ratingValue = Number::decimal(5.); - return std::ceil(ratingValue * 100) / 100; -} - std::string_view Commerce::discountType() { return Helper::arrayElement(discountTypes); } -std::string Commerce::discountCode() -{ - const std::integral auto codeLength = Number::integer(minDiscountCodeLength, maxDiscountCodeLength); - - return String::alphanumeric(codeLength, StringCasing::Upper); -} - -double Commerce::discountAmount() -{ - const std::floating_point auto amountValue = Number::decimal(minDiscountAmount, maxDiscountAmount); - - return std::ceil(amountValue * 100) / 100; -} - -double Commerce::discountPercentage() -{ - const std::floating_point auto percentageValue = - Number::decimal(minDiscountPercentage, maxDiscountPercentage); - - return std::ceil(percentageValue * 100) / 100; -} - -std::string Commerce::orderNumber() -{ - return String::numeric(7, true); -} - std::string_view Commerce::orderStatus() { return Helper::arrayElement(orderStatuses); diff --git a/src/modules/git/Git.cpp b/src/modules/git/Git.cpp index 0b7fbe10d..e997ad6b2 100644 --- a/src/modules/git/Git.cpp +++ b/src/modules/git/Git.cpp @@ -129,15 +129,4 @@ std::string Git::commitSha(unsigned length) return faker::String::hexadecimal(length, HexCasing::Lower, HexPrefix::None); } -Git::Author Git::author() -{ - const auto firstName = static_cast(Person::firstName()); - const auto lastName = static_cast(Person::lastName()); - - const auto name = firstName + " " + lastName; - const auto email = Internet::email(firstName, lastName); - - return {name, email}; -} - } diff --git a/src/modules/person/Person.cpp b/src/modules/person/Person.cpp index 78ce98a71..cda04a598 100644 --- a/src/modules/person/Person.cpp +++ b/src/modules/person/Person.cpp @@ -222,11 +222,6 @@ std::string_view Person::lastName(std::optional countryOpt, std::option return Helper::arrayElement(lastNames); } -std::string_view Person::middleName(std::optional countryOpt, std::optional sex) -{ - return firstName(countryOpt, sex); -} - std::string Person::fullName(std::optional countryOpt, std::optional sex) { const auto country = countryOpt ? *countryOpt : Country::England; @@ -244,10 +239,9 @@ std::string Person::fullName(std::optional countryOpt, std::optional>{ {"firstName", [&country, &sex]() { return std::string{firstName(country, sex)}; }}, - {"middleName", [&country, &sex]() { return std::string{middleName(country, sex)}; }}, {"lastName", [&country, &sex]() { return std::string{lastName(country, sex)}; }}, - {"prefix", [&country, &sex]() { return std::string{middleName(country, sex)}; }}, - {"suffix", [&country, &sex]() { return std::string{middleName(country, sex)}; }}}; + {"prefix", [&country, &sex]() { return std::string{prefix(country, sex)}; }}, + {"suffix", [&country, &sex]() { return std::string{suffix(country, sex)}; }}}; return FormatHelper::fillTokenValues(nameFormat, dataGeneratorsMapping); } diff --git a/src/modules/person/PersonData.cpp b/src/modules/person/PersonData.cpp index 56974e88c..825b42c62 100644 --- a/src/modules/person/PersonData.cpp +++ b/src/modules/person/PersonData.cpp @@ -4056,7 +4056,7 @@ const std::array danishMalePrefixes{"hr."}; const std::array danishFemalePrefixes{"fr."}; -const NameFormats danishNameFormats{{{"{firstName} {lastName}", 1}, {"{firstName} {middleName} {lastName}", 1}}}; +const NameFormats danishNameFormats{{{"{firstName} {lastName}", 1}, {"{firstName} {lastName}", 1}}}; const PeopleNames danishPeopleNames{{danishMaleFirstNames, danishMalePrefixes, {}, {}}, {danishFemaleFirstNames, danishLastNames, danishFemalePrefixes, {}}, @@ -10068,10 +10068,7 @@ const std::array russianFemaleLastNames = { "Шубина", "Шувалова", "Шульгина", "Щеглова", "Щербакова", "Щукина", "Юдина", "Яковлева", "Яшина"}; -const NameFormats russianNameFormats{{{"{firstName} {lastName}", 1}, - {"{lastName} {firstName}", 1}, - {"{lastName} {middleName} {firstName}", 1}, - {"{lastName} {firstName} {middleName}", 1}}}; +const NameFormats russianNameFormats{{{"{firstName} {lastName}", 1}, {"{lastName} {firstName}", 1}}}; const PeopleNames russianPeopleNames{{russianMaleFirstNames, russianMaleLastNames, {}, {}}, {russianFemaleFirstNames, russianFemaleLastNames, {}, {}}, @@ -11712,8 +11709,6 @@ const std::array ukrainianFemalePrefixes{"Пані"}; const NameFormats ukrainianNameFormats{{ {"{firstName} {lastName}", 1}, {"{lastName} {firstName}", 1}, - {"{firstName} {middleName} {lastName}", 1}, - {"{lastName} {middleName} {firstName}", 1}, }}; const PeopleNames ukrainianPeopleNames{ diff --git a/src/modules/weather/Weather.cpp b/src/modules/weather/Weather.cpp index 40628ec77..848fab0b2 100644 --- a/src/modules/weather/Weather.cpp +++ b/src/modules/weather/Weather.cpp @@ -3,61 +3,12 @@ #include #include "faker-cxx/Helper.h" -#include "faker-cxx/Number.h" #include "WeatherData.h" namespace faker { - -Weather::Temperature Weather::temperature() -{ - double metric = Number::decimal(10.0, 30.0); - - double imperial = (metric * 9.0 / 5.0) + 32; - - return {metric, imperial}; -} - -Weather::Pressure Weather::pressure() -{ - double metric = Number::decimal(100.0, 102.0); - - double imperial = metric * 0.14503773773375; - - return {metric, imperial}; -} - -Weather::Visibility Weather::visibility() -{ - double metric = Number::decimal(1.0, 10.0); - - double imperial = metric * 1.609344; - - return {metric, imperial}; -} - -Weather::WindSpeed Weather::windSpeed() -{ - return {Number::decimal(0.1, 24.2), Number::decimal(0.1, 15.0)}; -} - -int Weather::uvIndex() -{ - return Number::integer(0, 11); -} - -int Weather::humidity() -{ - return Number::integer(0, 100); -} - std::string_view Weather::weatherDescription() { return Helper::arrayElement(weatherDescriptions); } - -int Weather::cloudCover() -{ - return Number::integer(0, 100); -} } diff --git a/tests/modules/book/BookTest.cpp b/tests/modules/book/BookTest.cpp index 38c200e64..489922b45 100644 --- a/tests/modules/book/BookTest.cpp +++ b/tests/modules/book/BookTest.cpp @@ -6,7 +6,6 @@ #include "gtest/gtest.h" #include "book/BookData.h" -#include "common/StringHelper.h" using namespace ::testing; using namespace faker; @@ -47,28 +46,6 @@ TEST_F(BookTest, shouldGeneratePublisher) { return publisher == bookPublisher; })); } -TEST_F(BookTest, shouldGenerateIsbn) -{ - const auto bookIsbn = Book::isbn(); - - const auto isbnNumbersGroups = StringHelper::split(bookIsbn, "-"); - - ASSERT_EQ(bookIsbn.size(), 17); - ASSERT_EQ(isbnNumbersGroups[0].size(), 3); - ASSERT_EQ(isbnNumbersGroups[1].size(), 2); - ASSERT_EQ(isbnNumbersGroups[2].size(), 2); - ASSERT_EQ(isbnNumbersGroups[3].size(), 5); - ASSERT_EQ(isbnNumbersGroups[4].size(), 1); -} - -TEST_F(BookTest, shouldGenerateTranslator) -{ - const auto bookTranslator = Book::translator(); - - ASSERT_TRUE(std::ranges::any_of(translators, [bookTranslator](const std::string_view& translator) - { return translator == bookTranslator; })); -} - TEST_F(BookTest, shouldGenerateFormat) { const auto bookFormat = Book::format(); diff --git a/tests/modules/commerce/CommerceTest.cpp b/tests/modules/commerce/CommerceTest.cpp index b29bdd914..5ea9743fa 100644 --- a/tests/modules/commerce/CommerceTest.cpp +++ b/tests/modules/commerce/CommerceTest.cpp @@ -1,8 +1,6 @@ #include "faker-cxx/Commerce.h" #include -#include -#include #include #include "gtest/gtest.h" @@ -27,21 +25,6 @@ TEST_F(CommerceTest, shouldGenerateCommerceDepartment) { return department == generatedDepartment; })); } -TEST_F(CommerceTest, shouldGeneratePrice) -{ - const auto generatedPrice = Commerce::price(100, 10000); - - auto offset = generatedPrice.size(); - const auto priceAsFloat = std::stof(generatedPrice, &offset); - - const auto generatedPriceElements = StringHelper::split(generatedPrice, "."); - - ASSERT_EQ(generatedPriceElements.size(), 2); - ASSERT_EQ(generatedPriceElements[1].size(), 2); - ASSERT_GE(priceAsFloat, 100); - ASSERT_LE(priceAsFloat, 10000); -} - TEST_F(CommerceTest, shouldGenerateSku) { const auto sku = Commerce::sku(); @@ -204,14 +187,6 @@ TEST_F(CommerceTest, shouldGenerateIsbn10) ASSERT_TRUE(sum % 11 == 0); } -TEST_F(CommerceTest, shouldGenerateProductId) -{ - const auto generatedProductId = Commerce::productId(); - - ASSERT_EQ(generatedProductId.length(), 10); - ASSERT_TRUE(std::ranges::all_of(generatedProductId, [](const char& c) { return std::isalnum(c); })); -} - TEST_F(CommerceTest, shouldGeneratePaymentType) { const auto generatedPaymentType = Commerce::paymentType(); @@ -255,13 +230,6 @@ TEST_F(CommerceTest, shouldGenerateProductReview) { return productReview == generatedProductReview; })); } -TEST_F(CommerceTest, shouldGenerateProductRating) -{ - const auto generatedProductRating = Commerce::productRating(); - - ASSERT_TRUE(0. <= generatedProductRating && generatedProductRating <= 5.); -} - TEST_F(CommerceTest, shouldGenerateDiscountType) { const auto generatedDiscountType = Commerce::discountType(); @@ -270,46 +238,6 @@ TEST_F(CommerceTest, shouldGenerateDiscountType) { return discountType == generatedDiscountType; })); } -TEST_F(CommerceTest, shouldGenerateDiscountCode) -{ - - const auto generatedDiscountCode = Commerce::discountCode(); - - ASSERT_TRUE(minDiscountCodeLength <= generatedDiscountCode.length() && - generatedDiscountCode.length() <= maxDiscountCodeLength); - - ASSERT_TRUE(std::ranges::all_of(generatedDiscountCode, - [](char generatedDiscountCodeCharacter) - { - return std::ranges::any_of( - upperAlphanumericCharacters, - [generatedDiscountCodeCharacter](char upperAlphanumericCharacter) - { return upperAlphanumericCharacter == generatedDiscountCodeCharacter; }); - })); -} - -TEST_F(CommerceTest, shouldGenerateDiscountAmount) -{ - const auto generatedDiscountAmount = Commerce::discountAmount(); - - ASSERT_TRUE(minDiscountAmount <= generatedDiscountAmount && generatedDiscountAmount <= maxDiscountAmount); -} - -TEST_F(CommerceTest, shouldGenerateDiscountPercentage) -{ - const auto generatedDiscountPercentage = Commerce::discountPercentage(); - - ASSERT_TRUE(minDiscountPercentage <= generatedDiscountPercentage && - generatedDiscountPercentage <= maxDiscountPercentage); -} - -TEST_F(CommerceTest, shouldGenerateOrderNumber) -{ - const auto generatedOrderNumber = Commerce::orderNumber(); - - ASSERT_EQ(generatedOrderNumber.length(), 7); -} - TEST_F(CommerceTest, shouldGenerateOrderStatus) { const auto generatedOrderStatus = Commerce::orderStatus(); diff --git a/tests/modules/git/GitTest.cpp b/tests/modules/git/GitTest.cpp index 50cf765fa..4c35c0e4e 100644 --- a/tests/modules/git/GitTest.cpp +++ b/tests/modules/git/GitTest.cpp @@ -105,15 +105,3 @@ TEST_F(GitTest, shouldGenerateCommitSha) ASSERT_TRUE(std::regex_match(Git::commitSha(length), shaRegex)); } - -TEST_F(GitTest, shouldGenerateAuthor) -{ - const auto generatedAuthor = Git::author(); - - const std::regex nameRegex(NAME_REGEX); - - const std::regex emailRegex(EMAIL_REGEX); - - ASSERT_TRUE(std::regex_match(generatedAuthor.name, nameRegex)); - ASSERT_TRUE(std::regex_match(generatedAuthor.email, emailRegex)); -} diff --git a/tests/modules/weather/WeatherTest.cpp b/tests/modules/weather/WeatherTest.cpp index ecf7de6ec..8cebce9c3 100644 --- a/tests/modules/weather/WeatherTest.cpp +++ b/tests/modules/weather/WeatherTest.cpp @@ -15,52 +15,6 @@ class WeatherTest : public Test public: }; -TEST_F(WeatherTest, shouldGenerateTemperature) -{ - Weather::Temperature generatedTemperature = Weather::temperature(); - - ASSERT_TRUE(generatedTemperature.metric >= 10 && generatedTemperature.metric <= 30); - ASSERT_TRUE(generatedTemperature.imperial >= 50 && generatedTemperature.imperial <= 90); -} - -TEST_F(WeatherTest, shouldGeneratePressure) -{ - Weather::Pressure generatedPressure = Weather::pressure(); - - ASSERT_TRUE(generatedPressure.metric >= 100.0 && generatedPressure.metric <= 102.0); - ASSERT_TRUE(generatedPressure.imperial >= 14.5 && generatedPressure.imperial <= 14.8); -} - -TEST_F(WeatherTest, shouldGenerateVisibility) -{ - Weather::Visibility generatedVisibility = Weather::visibility(); - - ASSERT_TRUE(generatedVisibility.metric >= 1 && generatedVisibility.metric <= 10.0); - ASSERT_TRUE(generatedVisibility.imperial >= 1.6 && generatedVisibility.imperial <= 16.1); -} - -TEST_F(WeatherTest, shouldGenerateWindSpeed) -{ - Weather::WindSpeed generatedWindSpeed = Weather::windSpeed(); - - ASSERT_TRUE(generatedWindSpeed.metric >= 0.1 && generatedWindSpeed.metric <= 24.2); - ASSERT_TRUE(generatedWindSpeed.imperial >= 0.1 && generatedWindSpeed.imperial <= 15.0); -} - -TEST_F(WeatherTest, shouldGenerateUvIndex) -{ - int generatedUvIndex = Weather::uvIndex(); - - ASSERT_TRUE(generatedUvIndex >= 0 && generatedUvIndex <= 11); -} - -TEST_F(WeatherTest, shouldGenerateHumidity) -{ - int generatedHumidity = Weather::humidity(); - - ASSERT_TRUE(generatedHumidity >= 0 && generatedHumidity <= 100); -} - TEST_F(WeatherTest, shouldGenerateWeatherDescription) { const std::string_view generatedWeatherDescription = Weather::weatherDescription(); @@ -69,10 +23,3 @@ TEST_F(WeatherTest, shouldGenerateWeatherDescription) [generatedWeatherDescription](const std::string_view& weatherDescription) { return weatherDescription == generatedWeatherDescription; })); } - -TEST_F(WeatherTest, shouldGenerateWeatherCloudCover) -{ - int generatedCloudCover = Weather::cloudCover(); - - ASSERT_TRUE(generatedCloudCover >= 0 && generatedCloudCover <= 100); -}