• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

eric15342335 / comp2113-engg1340-group-project / #13

12 Jun 2024 04:31PM UTC coverage: 67.084% (+0.08%) from 67.005%
#13

push

travis-ci

web-flow
Fix 'For loop variable changed in body' issue (#138)

43 of 48 new or added lines in 3 files covered. (89.58%)

17 existing lines in 2 files now uncovered.

1341 of 1999 relevant lines covered (67.08%)

4298418.92 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.0
/src/names.cpp
1
/// @file names.cpp
2
/// Implementation of the stock name generation functions.
3
/*
4
This program is free software: you can redistribute it and/or modify it under the
5
terms of the GNU Lesser General Public License as published by the Free Software
6
Foundation, either version 3 of the License, or (at your option) any later version.
7

8
This program is distributed in the hope that it will be useful, but WITHOUT ANY
9
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
10
PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
11

12
You should have received a copy of the GNU Lesser General Public License along with this
13
program. If not, see <https://www.gnu.org/licenses/>.
14
*/
15
#include "names.h"
16

17
#include "random_price.h"
18

19
#include <algorithm>
20
using namespace std;
21

22
string const category_list[category_list_size] = {"Adv&Market", "Aero&Def", "Airlines",
23
    "RenewEnergy", "Auto", "Banks", "Biotech", "Broadcast", "Casinos&Gaming",
24
    "E-Commerce", "FinServices", "Food&Beverage", "Healthcare", "Tech", "RealEstate",
25
    "Retail", "Telecom"};
26

27
/**
28
 * @brief Generates a set of unique stock names based on the specified category and
29
 * quantity.
30
 * @param category The category index `[0 to category_list_size-1]` indicating the stock
31
 * category.
32
 * @param num The number of stock names to generate.
33
 * @return A vector of unique stock names.
34
 * @note There is a possibility of having an infinite loop if we called
35
 * `generate_names(0,99999999999999)`.
36
 */
37
vector<string> generate_name(unsigned int category, unsigned int num) {
40✔
38
    // List of suffixes for stock names
39
    vector<string> const suffixes = {"Holdings", "Ltd", "Group", "Corp", "Inc",
40
        "Enterprises", "Solutions", "Services"};
80✔
41
    vector<string> companyNames;
40✔
42

43
    switch (category) {
40✔
44
        case 0: { // Generate a name for Adv&Market category
4✔
45
            vector<string> words = {"Alpha", "Beta", "Gamma", "Delta", "Epsilon",
46
                "Innovate", "Solutions", "Strategies", "Impact", "Growth", "Creative",
47
                "Digital", "Marketing", "Brand", "Communications", "Buzz", "Genius",
48
                "Company", "Tech", "Global", "Dynamic", "Infinite", "Revolution",
49
                "Evolution", "Power", "Innovation", "Inspire", "Transform", "Future",
50
                "Vision", "Progress", "Solutions", "Excellence", "Advantage", "Success",
51
                "Fortune", "Ventures", "Endeavor", "Pioneers", "Prosperity", "Synergy",
52
                "Advertising", "Media", "Promotion", "Campaign", "Creative", "Strategy",
53
                "Market", "Audience", "Brand", "Digital", "Social", "Influencer"};
8✔
54

55
            pickUniqueNames(num, words, suffixes, companyNames);
4✔
56
            break;
4✔
57
        }
4✔
UNCOV
58
        case 1: { // Generate a name for Aero&Def category
×
59
            vector<string> words = {"Zeus", "Thor", "Hulk", "Loki", "Ironman",
60
                "Captain", "America", "Valkyrie", "Odin", "Hawkeye", "Levi",
61
                "Black Widow", "Vegeta", "Buu", "Sasuke", "Hephaestus", "Ares",
62
                "Poseidon", "Apollo", "Hera", "Athena", "Artemis", "Hades", "Hercules",
63
                "Mjolnir", "Stormbreaker", "Goku", "Shield", "Infinity", "Aizen",
64
                "Panther", "Anya", "Yor", "Goalkeeper", "Itachi", "Web", "Ant", "Man",
65
                "Groot", "Zhongli", "Lord", "Naruto", "Gojo", "Ichigo", "Kakashi",
66
                "Saitama", "Witch", "Air", "Wings", "Flight", "Rocket", "Defender",
67
                "Zeon", "Defense", "Airborne", "Aerospace", "Missile", "Anaheim",
68
                "Supersonic", "Bomber", "Interceptor", "Pilot", "Sukuna", "Stealth",
69
                "Warrior", "Aircraft", "Airman", "Seiya", "Sanji", "Airbase",
UNCOV
70
                "Stratosphere", "Airshow", "Combat", "Zoro"};
×
71

UNCOV
72
            pickUniqueNames(num, words, suffixes, companyNames);
×
UNCOV
73
            break;
×
74
        }
75
        case 2: { // Generate a name for Airlines category
2✔
76
            vector<string> words = {"Sky", "Wings", "Fly", "Jet", "Air", "Cloud",
77
                "Aviation", "Aero", "Flight", "High", "Travel", "Skyward", "Lift",
78
                "Airborne", "Airline", "Birds", "Wingman", "Up", "Glide", "Airbus",
79
                "Propel", "Cmefly", "Airfield", "Skyline", "Airspeed", "Aircrew",
80
                "Airshow", "Airspace", "Airway", "Aviator", "Airworthy", "Airstrip",
81
                "Airman", "Airfare", "Airbag", "Airbus", "Airtime", "Takeoff",
82
                "Landing", "Pilot", "Cabin", "Cockpit", "Airlift", "Airflow",
83
                "Airliner", "Jetsetter", "Airship", "Airterminal", "Airsteward",
84
                "Airstrike", "Airtaxi", "Airway"};
4✔
85

86
            pickUniqueNames(num, words, suffixes, companyNames);
2✔
87
            break;
2✔
88
        }
2✔
89
        case 3: { // Generate a name for RenewEnergy&storage category
2✔
90
            vector<string> words = {"Solar", "Wind", "Eco", "Green", "Renew", "Sunny",
91
                "Breezy", "Clean", "Efficient", "Power", "Sustainable", "Energize",
92
                "Hydro", "Turbine", "Electric", "Sunshine", "Gust", "Nature", "Windy",
93
                "Responsible", "Bio", "Geothermal", "Radiant", "Planet", "Emission",
94
                "Sizzle", "Zap", "Wave", "Harvest", "Air", "Biomass", "Carbon",
95
                "Efficiency", "Giga", "Innovate", "Mega", "Neutron", "Photon",
96
                "Renewable", "Revolve", "Spark", "Thermal", "Vortex", "Watt", "Zero",
97
                "PowerPunch", "JoltJester", "BatteryBanter", "EnergeticLaughs",
98
                "StorageSpark", "ChargeChuckler", "HumorHavoc", "FunnyFuel",
99
                "ZappyZingers", "WittyWatt", "EnergyVault", "PowerCell",
100
                "StorageSolutions", "ChargeMaster", "BatteryTech", "PowerHub",
101
                "EcoStorage", "RenewableEnergy", "EfficientEnergies", "EnergyVault",
102
                "PowerCell", "StorageSolutions", "ChargeMaster", "BatteryTech",
103
                "PowerHub", "EcoStorage", "RenewableEnergy", "EfficientEnergies"};
4✔
104

105
            pickUniqueNames(num, words, suffixes, companyNames);
2✔
106
            break;
2✔
107
        }
2✔
UNCOV
108
        case 4: { // Generate a name for Auto category
×
109
            vector<string> words = {"Speed", "Drive", "Auto", "Wheel", "Car", "Turbo",
110
                "Vroom", "Cruise", "Road", "Engine", "Flash", "Dom", "OnTheRoad",
111
                "Lightning", "Muskla", "Sleek", "Gizmo", "Adrenaline", "Fuel", "Bumper",
112
                "Sprint", "Beep", "Honk", "Mile", "Highway", "Chassis", "Rev", "Piston",
113
                "Gear", "Accelerate", "Tyre", "Brake", "Transmission", "Steering",
114
                "Ignition", "Convertible", "Stallion", "Cruiser", "Scooter", "Gadget",
115
                "Horsepower", "Dashboard", "Gearshift", "Muscle", "Auto", "Toyopa",
116
                "Honba", "Niisan", "Chevrolay", "Audio", "Mercidez", "BMX", "Lexxus",
117
                "Subaro", "Kio", "Cadillax", "Mitsubi", "Folksvagen", "Porshee", "Jeep",
118
                "Lambor", "Bentleey", "sherrari", "Rolling Roy", "Astton Lafite",
119
                "Mazdah", "Volvo", "Infinitii", "Alfa Romeo", "Lexus", "Sloth",
120
                "Land Hover", "Lincollin", "GMC", "Aubii", "Buddatti", "Maserahhi",
UNCOV
121
                "McLaren", "Rage Rover"};
×
122

UNCOV
123
            pickUniqueNames(num, words, suffixes, companyNames);
×
UNCOV
124
            break;
×
125
        }
126
        case 5: { // Generate a name for Banks category
1✔
127
            vector<string> words = {"Capital", "Trust", "Secure", "Savings", "Finest",
128
                "Elite", "Prosper", "Advance", "Global", "Infinite", "Vault", "Wealth",
129
                "First", "Premier", "Prime", "Harmony", "Velocity", "Pinnacle", "Noble",
130
                "Fortune", "Evergreen", "Summit", "Frontier", "Excellence", "Sovereign",
131
                "Centric", "Vantage", "Opus", "Paragon", "Zenith", "Crest", "Apex",
132
                "Aegis", "Legacy", "Crown", "Krupt", "Meridian", "Encompass", "Equity",
133
                "Stellar", "Eclipse"};
2✔
134

135
            pickUniqueNames(num, words, suffixes, companyNames);
1✔
136
            break;
1✔
137
        }
1✔
138
        case 6: { // Generate a name for Biotech category
5✔
139
            vector<string> words = {"GeneWorks", "BioSolutions", "CellTech", "InnoGene",
140
                "BioGenius", "VitaLab", "BioFusion", "GeneSynth", "EcoGene", "LifeTech",
141
                "BioMedix", "GenoInnovate", "BioNova", "GeneQuest", "BioSpark",
142
                "InnoCell", "BioRevolution", "GeneSense", "BioVital", "GeneXcel",
143
                "BioMatrix", "GeneScribe", "InnoGene", "BioNexus", "GeneLink",
144
                "BioTechne", "SynthoGene", "GeneWave", "BioGenome", "InnoBio",
145
                "GenePrime", "BioSpectra", "InnoCell", "BioPlasma", "GeneTech",
146
                "BioQuest", "GeneGenius", "InnoGene", "BioCure", "GeneCraft"};
10✔
147

148
            pickUniqueNames(num, words, suffixes, companyNames);
5✔
149
            break;
5✔
150
        }
5✔
151
        case 7: { // Generate a name for Broadcast category
5✔
152
            vector<string> words = {"SoundBlast", "MediaMania", "EchoFiesta",
153
                "ChannelChaos", "AudioCircus", "GlobalGiggles", "TalkTunes",
154
                "Listen2Laughs", "WaveWhimsy", "LiveLaughs", "Listen2Me",
155
                "StreamSmiles", "VoiceVortex", "RadioRuckus", "BroadcastBanter",
156
                "SonicSilliness", "AudioAmusement", "MediaMirth", "TalkTickles",
157
                "AudioWhoopee", "ListenUpLaughs", "StreamSilliness", "SoundPulse",
158
                "ChannelChuckles", "RadioRoars", "VoiceVibe", "EchoEntertainment",
159
                "AudioStreamers", "MediaLaughs", "TalkTrek", "WaveWire",
160
                "BroadcastBliss", "SonicStreamers", "SoundSerendipity",
161
                "AudioAmusement", "ListenInLaughs", "StreamCenter", "VoicePulse",
162
                "RadioRadar", "ChannelWave", "SoundSync", "SoundWave", "MediaCast",
163
                "EchoStream", "ChannelConnect", "AudioVision", "GlobalBroadcast",
164
                "TalkTime", "Listen2me", "WaveLink", "LiveAudio", "StreamSquad",
165
                "VoiceVortex", "RadioRevolution", "BroadcastHub", "SonicSignal",
166
                "AudioSphere", "MediaMingle", "TalkBox", "AudioWave", "ListenUp",
167
                "StreamStation", "SoundPulse", "ChannelChatter", "RadioRealm",
168
                "VoiceVibe", "EchoChannel", "AudioStream", "MediaVox", "TalkTrek",
169
                "WaveWire", "BroadcastBox", "SonicStream", "SoundSphere", "AudioMingle",
170
                "ListenIn", "StreamCenter", "VoicePulse", "RadioRadar", "ChannelWave",
171
                "SoundSync"};
10✔
172

173
            pickUniqueNames(num, words, suffixes, companyNames);
5✔
174
            break;
5✔
175
        }
5✔
176
        case 8: { // Generate a name for Casinos&Gaming category
1✔
177
            vector<string> words = {"LuckyBets", "GameGalore", "SpinToWin",
178
                "CasinoCraziness", "JackpotJamboree", "DiceyDelight", "GamblingGiggles",
179
                "CardComedy", "WagerWhimsy", "WinningLaughs", "ChipsChuckles",
180
                "PlayfulPoker", "SlotSilliness", "BingoBonanza", "RouletteRiot",
181
                "CasinoComedy", "GamingGalore", "BetBloopers", "GamblingGalore",
182
                "LaughingLottery", "SpinSmiles", "JokerJapes", "BlackjackBliss",
183
                "GameGiggles", "LuckyLaughter", "Splash of Clans", "DiceDelirium",
184
                "WagerWhoopee", "CardCapers", "WinningWhimsy", "ChipsChortle",
185
                "GTB VII", "GTC V", "HunterXHunter", "PlayfulPoker", "SlotSilliness",
186
                "BingoBanter", "RouletteRomp", "CasinoChuckles", "Monster Cooker World",
187
                "GamingGalore", "BetBloopers", "GamblingGalore", "LaughingLottery",
188
                "SpinSniggers", "Defence on Titan", "LuckyCasino", "GameCentral",
189
                "SpinWin", "CasinoHub", "JackpotCity", "Denshin Impact",
190
                "Splash Royale", "DiceGaming", "GamblingClub", "CardMaster",
191
                "WagerZone", "WinningStreak", "Road Fighter XI", "ChipsPalace",
192
                "PlayfulGaming", "SlotParadise", "BingoEmpire", "RouletteRealm",
193
                "Sudoku", "CasinoWorld", "GamingZone", "BetMasters", "GamblingKingdom",
194
                "LuckyLottery", "Cooking Papa", "SpinPalace", "JokerCasino",
195
                "BlackjackElite", "GameMaster", "LuckyWin", "ForNight", "WeCraft",
196
                "DiceGaming", "WagerZone", "CardMaster", "WinningStreak", "ChipsPalace",
197
                "Hokemon", "PlayfulGaming", "SlotParadise", "BingoEmpire",
198
                "RouletteRealm", "CasinoWorld", "MustLose", "GuaranteedWin",
199
                "GamingZone", "BetMasters", "GamblingKingdom", "LuckyLottery",
200
                "SpinPalace", "Nario"};
2✔
201

202
            pickUniqueNames(num, words, suffixes, companyNames);
1✔
203
            break;
1✔
204
        }
1✔
205
        case 9: { // Generate a name for E-Commerce category
3✔
206
            vector<string> words = {"Shopaholic", "Buy-o-matic", "DealDiva",
207
                "CartoonCraze", "SaleSensation", "Hundredcents", "Thousandcents",
208
                "DiscountDelight", "BargainBonanza", "OnlineOlympics", "ShipShop",
209
                "PricelessPurchases", "SkyDog", "Bmazon", "ClickComedy", "eBayLaughs",
210
                "AmazonAmusement", "ShoppingShenanigans", "VirtualVortex",
211
                "SaleSlapstick", "Buyer'sBliss", "DealDazzle", "CartoonCapers",
212
                "ShopSmart", "SkyCat", "BuyDirect", "DealFinder", "CartConnect",
213
                "SaleSpot", "DiscountMart", "BargainHunt", "OnlinePlaza", "ShipRight",
214
                "PricePoint", "ClickCentral", "eBayDeals", "AmazonEmporium",
215
                "ShoppingSolutions", "VirtualMarket", "SaleSolutions",
216
                "Buyer'sParadise", "DealHaven", "CartConnect"};
6✔
217

218
            pickUniqueNames(num, words, suffixes, companyNames);
3✔
219
            break;
3✔
220
        }
3✔
UNCOV
221
        case 10: { // Generate a name for FinServices category
×
222
            vector<string> words = {"CashComedy", "Dollar Dazzle", "FinanceFunnies",
223
                "WealthWhimsy", "MoneyMaster", "InvestmentLaughs", "Savings Smiles",
224
                "FunnyFunds", "PennyPunchlines", "BillsBanter", "CapitalConsulting",
225
                "WealthManagement", "FinancialSolutions", "MoneyMatters",
226
                "InvestmentAdvisors", "SecureBanking", "SmartFunds",
UNCOV
227
                "EconomicConsultancy", "FinancialExperts"};
×
228

UNCOV
229
            pickUniqueNames(num, words, suffixes, companyNames);
×
UNCOV
230
            break;
×
231
        }
232
        case 11: { // Generate a name for Food&Beverage category
3✔
233
            vector<string> words = {"Tasty", "Delicious", "Yummy", "Flavorful",
234
                "Gourmet", "Savor", "Flavors", "Satisfy", "Cuisine", "Culinary",
235
                "Taste", "Palate", "Savoring", "Bites", "Mouthwatering", "Bakery",
236
                "Cafe", "Catering", "Dining", "Juicy", "Zesty", "Fresh", "Spice", "Sip",
237
                "Brew", "Crave", "Snack", "Seasoned", "Saucy", "Wholesome", "Nourish",
238
                "Treats", "Feast", "Chew", "Munch", "Appetite", "Sip", "Gobble", "Gulp",
239
                "Plate", "Yum", "Morsel", "Nibble", "Digest", "Mouthful", "Bistro",
240
                "Savor", "Crunch", "Sizzle", "Devour"};
6✔
241

242
            pickUniqueNames(num, words, suffixes, companyNames);
3✔
243
            break;
3✔
244
        }
3✔
245
        case 12: { // Generate a name for Healthcare&Pharm category
1✔
246
            vector<string> words = {"Health", "Wellness", "Care", "Medical", "Life",
247
                "Apple/Day", "Vital", "Active", "Healthy", "Cure", "Recover", "Pay4Med",
248
                "Nourish", "Thrive", "Restore", "Revive", "Fit", "Strong", "Balance",
249
                "Medi", "Pharma", "Sana", "Sano", "Salute", "Pulse", "Vita",
250
                "Healthcare", "Wellbeing", "Medic", "Clinic", "Well", "Doctor", "Nurse",
251
                "Heal", "Surgery", "Wellness", "Rx", "Pharm", "Lab", "Medical",
252
                "Caring", "Healing", "Rehab", "Recovery", "Dose", "MediCare", "Medix",
253
                "Pharma", "Pharmaceutical", "Medi", "Health", "Care", "Wellness", "Rx",
254
                "Med", "Vita", "Sana", "Sano", "Salute", "Pulse", "Pharmacy",
255
                "Medicine", "Drugs", "Wellbeing", "Cure", "Heal", "Remedy", "Prescribe",
256
                "Relief", "Recovery", "Dose", "MediCare", "Medix", "Healthy", "Fit",
257
                "Strong", "Balance"};
2✔
258

259
            pickUniqueNames(num, words, suffixes, companyNames);
1✔
260
            break;
1✔
261
        }
1✔
262
        case 13: { // Generate a name for Tech category
2✔
263
            vector<string> words = {"Tech", "Digital", "Innovate", "Byte", "Code",
264
                "Data", "Logic", "Connect", "Smart", "Cyber", "Net", "Cloud", "Web",
265
                "Nerd", "Geek", "Infinite", "System", "Guru", "Genius", "Solve",
266
                "Pixel", "Bit", "Invent", "KKGarden"};
4✔
267

268
            pickUniqueNames(num, words, suffixes, companyNames);
2✔
269
            break;
2✔
270
        }
2✔
271
        case 14: { // Generate a name for RealEstate category
4✔
272
            vector<string> words = {"Real", "Estate", "Property", "Homes", "Realty",
273
                "Invest", "Buy", "Sell", "House", "Land", "Residential", "Commercial",
274
                "Development", "Build", "Investment", "Acres", "Estates", "Brokers",
275
                "Agents", "Mortgage", "Rent", "Lease", "Property", "Assets", "Housing",
276
                "Tower", "Plaza", "Villa", "Condo", "Develop", "Society", "Park",
277
                "Living", "Urban", "Suburban"};
8✔
278

279
            pickUniqueNames(num, words, suffixes, companyNames);
4✔
280
            break;
4✔
281
        }
4✔
282
        case 15: { // Generate a name for Retail category
3✔
283
            vector<string> words = {"Obsidian", "Velvetine", "Stellar", "Luminary",
284
                "Nebula", "Zephyr", "Elixir", "Intrigue", "Sapphire", "Crimson",
285
                "Aurora", "Celestial", "Enigma", "Mystique", "Euphoria", "Radiance",
286
                "Galaxy", "Harmonia", "Opulence", "Ethereal", "Curio", "Boutique",
287
                "Ethereal", "Nook", "Vivid", "Enchant", "Whimsy", "Delight",
288
                "Serendipity", "Wander", "Charm", "Spruce", "Eclectic", "Rustic",
289
                "Vintage"};
6✔
290

291
            pickUniqueNames(num, words, suffixes, companyNames);
3✔
292
            break;
3✔
293
        }
3✔
294
        case 16: { // Generate a name for Telecom category
4✔
295
            vector<string> words = {"Connect", "Link", "Wireless", "Tele", "Net",
296
                "Signal", "Comm", "Telecom", "Tech", "Mobile", "Global", "Data", "Wave",
297
                "Teleconnect", "Swift", "Talk", "Voice", "Fiber", "Reach", "OnCall",
298
                "Echo", "Pulse", "Synapse", "Velocity", "Empower", "Amplify",
299
                "Momentum", "Infinite", "Nexus", "Stream", "Sync", "Telepath",
300
                "Radiant", "Blaze", "Quantum"};
8✔
301

302
            pickUniqueNames(num, words, suffixes, companyNames);
4✔
303
            break;
4✔
304
        }
4✔
305
        default:
×
306
            /** "Group 88" is the fallback value for input category out of [0,
307
             * category_list_size - 1] */
308
            return std::vector<std::string>(1, "Group 88");
×
309
            break;
310
    }
311
    return companyNames;
40✔
312
}
40✔
313

314
void pickUniqueNames(const unsigned int & num, const vector<string> & words,
40✔
315
    const vector<string> & suffixes, vector<string> & companyNames) {
316
    /// @todo: add a test case or assertion
317
    /// @todo: use unordered_set instead of vector since we are checking for uniqueness
318
    decltype(num) pickedNamesAmount = num;
40✔
319
    while (companyNames.size() < pickedNamesAmount) {
80✔
320
        string name = words[random_integer(words.size())] + " " +
80✔
321
                      suffixes[random_integer(suffixes.size())];
80✔
322
        const bool companyNameAlreadyPresent =
323
            find(companyNames.begin(), companyNames.end(), name) == companyNames.end();
40✔
324
        if (companyNameAlreadyPresent) {
40✔
325
            companyNames.emplace_back(name);
40✔
326
        }
327
    }
40✔
328
}
40✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc