Too lazy to comment
This commit is contained in:
@@ -27,3 +27,10 @@ maps
|
|||||||
map test_export
|
map test_export
|
||||||
maps
|
maps
|
||||||
map ufo
|
map ufo
|
||||||
|
maps
|
||||||
|
map ad_obd
|
||||||
|
maps
|
||||||
|
map e4m3
|
||||||
|
tool_inspector
|
||||||
|
map e4m2
|
||||||
|
map ad_paradise
|
||||||
|
|||||||
186
mod_ad/ad_paradiseREADME.txt
Normal file
186
mod_ad/ad_paradiseREADME.txt
Normal file
@@ -0,0 +1,186 @@
|
|||||||
|
Paradise Sickness
|
||||||
|
===================
|
||||||
|
A Quake map for Arcane Dimensions
|
||||||
|
By: Redfield
|
||||||
|
-----------------------------------------------
|
||||||
|
|
||||||
|
Installation instructions:
|
||||||
|
|
||||||
|
1. To play this map you must first have the latest Arcane Dimensions mod installed in your Quake folder. To get Arcane Dimensions go to Quaddicted.com and download it.
|
||||||
|
|
||||||
|
2. Unzip all the files into your Quake/ad (Arcane Dimensions) directory. If you keep the file structure intact all the files will be installed correctly. This map includes new brush models, sound effects and a new skybox that must be installed in the correct folders in order to work correctly. The game will crash if the models are not in the correct folder. Simply copy the file structure in the zip if you have problems.
|
||||||
|
|
||||||
|
3. Launch Arcane Dimensions using your Quake engine of choice. This map supports Quakespasm (v0.92.1), Mark V (v1.0), and Darkplaces (2014/05/13 build).
|
||||||
|
|
||||||
|
4. Start a new game and select your skill pillar on the Arcane Dimensions start map, or bring down the console by pressing ~ and type <20>skill 0, 1, 2, or 3<> depending on your preference and press enter.
|
||||||
|
|
||||||
|
5. In the console type: "map ad_paradise" and press enter
|
||||||
|
|
||||||
|
6. Your journey begins...
|
||||||
|
|
||||||
|
=====
|
||||||
|
IMPORTANT NOTES:
|
||||||
|
|
||||||
|
-Darkplaces users must disable RT World lighting. It is not supported on this map.
|
||||||
|
|
||||||
|
-The map was tested on Quakespasm (v0.92.1), Quakespasm Spiked (v0.92.2), Mark V (v.1.0) and Darkplaces (2014/05/13 build). It may work on newer builds of Darkplaces but has not been tested. The map makes heavy use of the AD particle effects. It was designed with the pixelated particle style native to Quakespasm or Mark V in mind, but users can choose Quakespasm Spiked or Darkplaces for DP style special effects.
|
||||||
|
|
||||||
|
-This map is relatively dark, but was intended to be played with brightness and contrast set to the lowest level. If you find it too dark, I suggest increasing the brightness in small increments until you can see clearly.
|
||||||
|
|
||||||
|
-You may experience a glitch in which the player is hurt while moving on lifts. If this occurs it is recommended that you set the host_maxfps to 72 or lower in the console.
|
||||||
|
=====
|
||||||
|
|
||||||
|
========
|
||||||
|
The Skills:
|
||||||
|
========
|
||||||
|
|
||||||
|
Skill 0 <20> Easy: This mode was playtested with cats. My cat was able to beat this map on easy with minimal meowing. If you have a cat, or are a cat yourself, this mode is for you!
|
||||||
|
|
||||||
|
Skill 1 <20> Normal: Not showing off and not falling behind. You are a great adventurer, but sometimes you just want to relax.
|
||||||
|
|
||||||
|
Skill 2 <20> Hard: Only the chosen few can master this challenge and discover the path to true Paradise.
|
||||||
|
|
||||||
|
Skill 3 <20> Nightmare: You must be crazy<7A>
|
||||||
|
|
||||||
|
========
|
||||||
|
The Story:
|
||||||
|
========
|
||||||
|
|
||||||
|
It was the summer semester at Miskatonic University when I received a copy of the tattered old diary. It had been forwarded to me from an old friend that was in the midst of an archeological study in the Far East. He had recovered the few battered pages while studying the Leng Plateau, supposed home of the fabled "Kadath" mountains. Although who the author of the diary was has not been determined, it was revealed that they had been pursuing the same ancient cult my colleague was. Along with the diary my friend enclosed a letter explaining that he was convinced the cult of the Old Ones was currently operating somewhere deep in the Sahara region. It was clear that he intended to pursue this cult in order to satisfy his studies, despite the dangers in doing so.
|
||||||
|
|
||||||
|
It is not known exactly how this strange cult operates or what its motives are, but they are rumored to be in possession of a copy of the abhorred Necronomicon. My interest in this group of fanatics was weak, but it was the possibility that they possessed this book that piqued my interest. My profession as a historian of extinct cultures has given me limited exposure to the history of the Necronomicon, but of one thing I am certain: it is in fact based on a book much older than itself. Certain alchemical phrases and formula mentioned in the Necronomicon make reference to a text called "The Book of the Moon." It is this book that provides the alchemical knowledge relating to eternal youth and the philosopher's stone. It also makes cryptic reference to a realm of unparalleled beauty and majesty, a realm untouched even by the Old Ones, known only as "Paradise." It is the mention of this fabulous realm, also whispered of in other ancient cultures in my studies, that forms the basis of my current research.
|
||||||
|
|
||||||
|
This diary had arrived in the mail several months prior and I was planning a rendezvous with my old friend as soon as my responsibilities at the University could be passed to another professor, but today another letter arrived. I hold it in my hands at this moment, still in shock from its fantastical and terrifying revelations:
|
||||||
|
|
||||||
|
"My friend, I have tracked the cult deep into the Sahara, past even that Nameless City. Disguising myself as a workman proficient in digging, they have hired me to work on an excavation. How they found this place I can only guess. Deep in a ravine hidden in the shifting sands lies a Necropolis of the Egyptian gods. But beneath this, lie ruins even older. Ruins of city built by the Old Ones! It is true, we bring new artifacts to the surface each day. Something else has been found.. a Gate. The Gate is mentioned in several texts at the site, and they also mention the word "Paradise." Tensions are running high, and the researchers are attempting to rebuild the Gate. Armed guards have been posted, and I cannot move without suspicion. This may be the last letter I can send you. Coordinates of the Necropolis are attached. I hope to see you again when this has all been revealed..."
|
||||||
|
|
||||||
|
It is clear now that my friends' life may be in danger, but as scientists we often ignore such a thing in the face of discovery. I have arranged for a substitute to handle my classes, and have departed for the Sahara region. Am I a fool to endanger my life in this manner? How can I hope to confront this cult, an insidious group that has dogged mankind since its inception? My emotions are a tempest of horror and wild anticipation, but when I close my eyes I can see Paradise. I cannot turn back...
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
=============
|
||||||
|
Tips and Tricks
|
||||||
|
=============
|
||||||
|
-The player can explore the archeological base and ruins to find artifacts and other items in any manner they please, however it may be easier if you visit Dig Site A first.
|
||||||
|
-Keep an eye out for cracked and loose looking bricks, there may be hidden artifacts behind them!
|
||||||
|
-Remember in Arcane Dimensions things can be smashed, so get that axe out and start smashing.
|
||||||
|
-Keep on the lookout for computer consoles and books marked with floating runes. The information within may help you...
|
||||||
|
|
||||||
|
=======
|
||||||
|
Credits:
|
||||||
|
=======
|
||||||
|
Author: Ryan "Redfield" Johnston
|
||||||
|
contact: credfield099@gmail.com
|
||||||
|
|
||||||
|
Testing and feedback:
|
||||||
|
Lane Powell
|
||||||
|
Ionous
|
||||||
|
Negke
|
||||||
|
|
||||||
|
Technical help:
|
||||||
|
EricW
|
||||||
|
Spike
|
||||||
|
Negke
|
||||||
|
Sock
|
||||||
|
|
||||||
|
Tools:
|
||||||
|
Trenchbroom 2.0 by Sleepwalker
|
||||||
|
Tyrutils v0.15.10 by EricW
|
||||||
|
Compiling GUI by Necros
|
||||||
|
Texmex by Mike Jackman
|
||||||
|
Goldwave by Goldwave Inc.
|
||||||
|
|
||||||
|
Many of the textures in the map come from the ikbase set by Ikka Kernen and the Sock's Egyptian set.
|
||||||
|
|
||||||
|
New textures and sounds created/edited by Redfield
|
||||||
|
Some of the textures and sounds contain copyright material. This map is not being distributed for monetary gain. No copyright infringement is intended. Wolf's Rain is the property of Bones Studio. Sonic the Hedgehog is the property of Sega Games. Indiana Jones is the property of Disney Studios. Quake is the property of idSoftware.
|
||||||
|
|
||||||
|
I would also like to thank everyone at func_msgboard for all their support and feedback over the months. Also thank-you everyone who is part of the Quake scene overall for keeping the game alive.
|
||||||
|
|
||||||
|
|
||||||
|
===========
|
||||||
|
Map Details:
|
||||||
|
===========
|
||||||
|
|
||||||
|
This map was started while I was still working on my first map Unknown Kadath (which you should play if you haven't!) While my first map was made to be playable in WinQuake it was thus very limited in scale and complexity. When working on this map I wanted it to be much larger and incorporate many new features. I had been playing Arcane Dimensions recently and decided that this mod would be perfect for my next map. I have always like the Dissolution of Eternity pack and the map Curse of Osiris, and the Egyptian theme is very popular in Quake. I knew I wanted to make an Egyptain map, but wanted to do something more with it. I also have played through "Operation Urth Majik" and was inspired to make a base map that blended with an Egypt map. Urth Majik had a uniue story, but was split up into several maps, and for my map I wanted the base and egypt parts all in one map.
|
||||||
|
|
||||||
|
At this point I started to develop the story for a shadowy organization that had discovered some ancient ruins and built an archeological base around them. I had also been watching the very impressive anime series Wolf's Rain, and was inspired by the idea of "Paradise" and the strange eastern alchemical lore in the anime. The story eventually grew to involve a quest for Paradise, and the struggle to stop the "Cult of the Old Ones" from obtaining it. With the story in place I had an idea of the type of environments I wanted the player to explore and could set out making the map.
|
||||||
|
|
||||||
|
I looked at images of ancient Egyptian ruins, and some of the architecture of the map is designed after these images. Ancient Egypt has a lot of square shapes and simple designs and this is perfect for using brushes. The research lab sections are admittedly quite simple. My career is in hematology so I had the idea to set up the lab as it might look in a real word hospital setting. This means essentially a large square room, or connected square rooms where samples can easily be delivered to other workstations. Obviously it is tweaked to make it more interesting, but the lab layout is really very simple and square like. The overall square shape of many of the rooms made it easier for a new mapper to build, and then detail brushes were added inside the rooms to change the shape and make the environment interesting.
|
||||||
|
|
||||||
|
I played around with a lot of rotating objects in this map, and it really is something that Quake is not meant to do. There are no physics, and the brushes that the player can interact with do not actually rotate, so hidden "physics" brushes are placed to mimic movement. This was really time consuming and at one point I considered dropping the rotating bridge altogether. Persistence payed off in the end though, and I am happy to have these rotating objects in the map. The map source is included to look at as it may have some interesting things for mappers to see. The map grew to have 11 032 brushes and initially had to be compiled as a bsp2 map. After some technical help from Negke I was able to get the map to compile as a regular bsp by using the new func_detail_wall entity in EricWs tools.
|
||||||
|
|
||||||
|
Overall the map took about 6 months to make working as often as possible. I hope players enjoy their journey in Paradise Sickness. No one can say what the future holds now, but if one perseveres Paradise may be attainable after all...
|
||||||
|
|
||||||
|
|
||||||
|
===========
|
||||||
|
Secrets Guide:
|
||||||
|
===========
|
||||||
|
|
||||||
|
Spoilers below!
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
----------------------------
|
||||||
|
Spoilers start here!
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
Secret #1. The Smuggler's Secret: When entering the large valley of the Necropolis, the player sees a Sphinx and a large Pyramid. There is a small oasis to the left of the Sphinx. Explore the waterfall there and you may find a dark secret waiting.
|
||||||
|
|
||||||
|
Secret #2. The Loose Brick Secret: When in Dig Site A you will eventually drop into a huge water filled cavern with a bridge. Upon first entering a large room with a column in the center guarded by many knights, you will see a high ledge with an archer and a yellow armor. The armor seems impossible to reach from here, but if you go outside the room near the armor you will see many loose bricks forming a staircase. Jump up here and use your axe to get through.
|
||||||
|
|
||||||
|
Secret #3. The Fishy Secret: In the same area of Dig Site A take a dive into the water and swim around. Out near the rotating bridge you will see many loose bricks under the water. Some of these have a clear passageway beyond...
|
||||||
|
|
||||||
|
Secret #4. The Electrifying Secret: In Dig Site A there is a large temple with many lightning shooters around the room. The player will be attacked by ogres and wizards on high ledges. If you jump onto the slanted railing in the center of the room you can jump to these ledges. One of them has something interesting.
|
||||||
|
|
||||||
|
Secret #5. The Eagle Eye Secret: After leaving Dig Site A the player moves to the Processing lab. There is a grated panel under a fan near the lab. You can't break it but there is a shootable switch nearby. Try looking at the ceiling inside the processing room.
|
||||||
|
|
||||||
|
Secret #6. Raider of the Lost Secret: After getting the gold keycard and leaving Processing the player is ambushed by guards in Storage. Kill them all and explore the storage area. There are many smashable crates here, and what appears to be a blinking light...
|
||||||
|
|
||||||
|
Secret #7. The Mummy Returns: In Dig Site B the player will enter a temple and obtain a new axe for slaying mummies. After getting the axe the player will move to a room with two sarcophagi and a red armor. Look near one of the sarcophagi and you will see a secret room with a grenade launcher. There is a switch that moves the sarcophagus on the wall above you. Shoot it. Is that Rachel Weisz and Brendan Fraser in Quake?
|
||||||
|
|
||||||
|
Secret #8. Won't Get Fooled Again: So how the heck do you get that red armor now? After surviving the Indiana boulder the player will enter a blue temple guarded by stone knights. Behind one of these knights is a cracked wall that can be smashed down to reveal a secret corridor.
|
||||||
|
|
||||||
|
Secret #9. The Wolf's Lair: Inside the Great Hall with massive stone columns in Dig Site B there is a pool with a waterfall. After the player activates the lifts and climbs up to the sun artifact you can see many chains holding it up. You can move onto these chains and you may see to arrows giving you a hint where to go. If you look down you will see a floating platform far below. Take a leap of faith and the platform will lead you to a hidden switch. This opens the central pool that takes you to the lair of the Wolf...
|
||||||
|
|
||||||
|
Secret #10. The Secret of the Sphinx: We all knew there was something buried under the Sphinx. You must obtain the Wolf's secret to solve the Sphinx's riddle. Return to the Sphinx and a new passage will be revealed to you...
|
||||||
|
|
||||||
|
Secret #11. The Super Secret: It is rumored that a strange blue hedgehog has been spotted in the region. Deep below the Sphinx in the chamber with the hourglasses there is a strange symbol hidden in the room. Is this somehow connected to that hedgehog?
|
||||||
|
|
||||||
|
For NoClippers: There are a couple of textures that were going to be incorporated into a larger secret but it was eventually scrapped. I kept two of these textures in the map because they made me laugh. If you explore near the entrance to Paradise with noclip you might find them!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
------------------
|
||||||
|
End spoilers
|
||||||
|
------------------
|
||||||
|
|
||||||
|
==========
|
||||||
|
Disclaimer
|
||||||
|
==========
|
||||||
|
|
||||||
|
Do not distribute this map for monetary gain.
|
||||||
|
If you wish to share this map with others please include this readme and credit me Refield as the author.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Thanks for reading!
|
||||||
|
|
||||||
|
Redfield
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
116371
mod_ad/auto_save_0.sav
116371
mod_ad/auto_save_0.sav
File diff suppressed because it is too large
Load Diff
106552
mod_ad/auto_save_1.sav
106552
mod_ad/auto_save_1.sav
File diff suppressed because it is too large
Load Diff
60521
mod_ad/auto_save_2.sav
60521
mod_ad/auto_save_2.sav
File diff suppressed because it is too large
Load Diff
@@ -177,7 +177,7 @@ r_viewmodel_offset "0"
|
|||||||
r_viewmodel_quake "0"
|
r_viewmodel_quake "0"
|
||||||
r_viewmodel_ring "1"
|
r_viewmodel_ring "1"
|
||||||
r_viewmodel_size "0"
|
r_viewmodel_size "0"
|
||||||
r_wateralpha "0.800"
|
r_wateralpha "0.650"
|
||||||
r_waterripple "0"
|
r_waterripple "0"
|
||||||
r_waterwarp "1"
|
r_waterwarp "1"
|
||||||
r_waterwarp_amp "150"
|
r_waterwarp_amp "150"
|
||||||
|
|||||||
BIN
mod_ad/gfx/env/sahara_bk.tga
vendored
Normal file
BIN
mod_ad/gfx/env/sahara_bk.tga
vendored
Normal file
Binary file not shown.
BIN
mod_ad/gfx/env/sahara_dn.tga
vendored
Normal file
BIN
mod_ad/gfx/env/sahara_dn.tga
vendored
Normal file
Binary file not shown.
BIN
mod_ad/gfx/env/sahara_ft.tga
vendored
Normal file
BIN
mod_ad/gfx/env/sahara_ft.tga
vendored
Normal file
Binary file not shown.
BIN
mod_ad/gfx/env/sahara_lf.tga
vendored
Normal file
BIN
mod_ad/gfx/env/sahara_lf.tga
vendored
Normal file
Binary file not shown.
BIN
mod_ad/gfx/env/sahara_rt.tga
vendored
Normal file
BIN
mod_ad/gfx/env/sahara_rt.tga
vendored
Normal file
Binary file not shown.
BIN
mod_ad/gfx/env/sahara_up.tga
vendored
Normal file
BIN
mod_ad/gfx/env/sahara_up.tga
vendored
Normal file
Binary file not shown.
BIN
mod_ad/maps/ad_paradise.bsp
Normal file
BIN
mod_ad/maps/ad_paradise.bsp
Normal file
Binary file not shown.
BIN
mod_ad/maps/ad_paradise.lit
Normal file
BIN
mod_ad/maps/ad_paradise.lit
Normal file
Binary file not shown.
121911
mod_ad/maps/ad_paradise.map
Normal file
121911
mod_ad/maps/ad_paradise.map
Normal file
File diff suppressed because it is too large
Load Diff
BIN
mod_ad/maps/base_brk/ad_concrete.bsp
Normal file
BIN
mod_ad/maps/base_brk/ad_concrete.bsp
Normal file
Binary file not shown.
BIN
mod_ad/maps/base_brk/ad_greybrick.bsp
Normal file
BIN
mod_ad/maps/base_brk/ad_greybrick.bsp
Normal file
Binary file not shown.
BIN
mod_ad/maps/base_brk/ad_greybrick2.bsp
Normal file
BIN
mod_ad/maps/base_brk/ad_greybrick2.bsp
Normal file
Binary file not shown.
BIN
mod_ad/maps/base_brk/ad_indyrubble.bsp
Normal file
BIN
mod_ad/maps/base_brk/ad_indyrubble.bsp
Normal file
Binary file not shown.
BIN
mod_ad/maps/base_brk/ad_sandstone.bsp
Normal file
BIN
mod_ad/maps/base_brk/ad_sandstone.bsp
Normal file
Binary file not shown.
BIN
mod_ad/maps/base_brk/baserub1_paradise.bsp
Normal file
BIN
mod_ad/maps/base_brk/baserub1_paradise.bsp
Normal file
Binary file not shown.
BIN
mod_ad/maps/base_brk/baserub2_paradise.bsp
Normal file
BIN
mod_ad/maps/base_brk/baserub2_paradise.bsp
Normal file
Binary file not shown.
BIN
mod_ad/maps/base_brk/ikcrate_r1.bsp
Normal file
BIN
mod_ad/maps/base_brk/ikcrate_r1.bsp
Normal file
Binary file not shown.
BIN
mod_ad/maps/base_brk/ikcrate_r2.bsp
Normal file
BIN
mod_ad/maps/base_brk/ikcrate_r2.bsp
Normal file
Binary file not shown.
BIN
mod_ad/maps/base_brk/paradise_column1.bsp
Normal file
BIN
mod_ad/maps/base_brk/paradise_column1.bsp
Normal file
Binary file not shown.
BIN
mod_ad/maps/base_brk/paradise_column1.lit
Normal file
BIN
mod_ad/maps/base_brk/paradise_column1.lit
Normal file
Binary file not shown.
BIN
mod_ad/maps/base_brk/paradise_column2.bsp
Normal file
BIN
mod_ad/maps/base_brk/paradise_column2.bsp
Normal file
Binary file not shown.
BIN
mod_ad/maps/base_brk/paradise_column2.lit
Normal file
BIN
mod_ad/maps/base_brk/paradise_column2.lit
Normal file
Binary file not shown.
BIN
mod_ad/maps/base_brk/wood_paradise.bsp
Normal file
BIN
mod_ad/maps/base_brk/wood_paradise.bsp
Normal file
Binary file not shown.
65146
mod_ad/quick.sav
Normal file
65146
mod_ad/quick.sav
Normal file
File diff suppressed because it is too large
Load Diff
BIN
mod_ad/sound/ambience/bigmachine_withcues.wav
Normal file
BIN
mod_ad/sound/ambience/bigmachine_withcues.wav
Normal file
Binary file not shown.
BIN
mod_ad/sound/ambience/computer_ambience.wav
Normal file
BIN
mod_ad/sound/ambience/computer_ambience.wav
Normal file
Binary file not shown.
BIN
mod_ad/sound/ambience/evacuate.wav
Normal file
BIN
mod_ad/sound/ambience/evacuate.wav
Normal file
Binary file not shown.
BIN
mod_ad/sound/ambience/indiana.wav
Normal file
BIN
mod_ad/sound/ambience/indiana.wav
Normal file
Binary file not shown.
BIN
mod_ad/sound/ambience/s_ring.wav
Normal file
BIN
mod_ad/sound/ambience/s_ring.wav
Normal file
Binary file not shown.
BIN
mod_ad/sound/ambience/shortexp.wav
Normal file
BIN
mod_ad/sound/ambience/shortexp.wav
Normal file
Binary file not shown.
BIN
mod_ad/sound/ambience/snake_hiss.wav
Normal file
BIN
mod_ad/sound/ambience/snake_hiss.wav
Normal file
Binary file not shown.
BIN
mod_ad/sound/ambience/starpost.wav
Normal file
BIN
mod_ad/sound/ambience/starpost.wav
Normal file
Binary file not shown.
BIN
mod_ad/sound/ambience/waterfall_loop.wav
Normal file
BIN
mod_ad/sound/ambience/waterfall_loop.wav
Normal file
Binary file not shown.
BIN
mod_ad/sound/ambience/wolf.wav
Normal file
BIN
mod_ad/sound/ambience/wolf.wav
Normal file
Binary file not shown.
File diff suppressed because it is too large
Load Diff
7358
mod_vanilla/auto_save_1.sav
Normal file
7358
mod_vanilla/auto_save_1.sav
Normal file
File diff suppressed because it is too large
Load Diff
4131
mod_vanilla/auto_save_2.sav
Normal file
4131
mod_vanilla/auto_save_2.sav
Normal file
File diff suppressed because it is too large
Load Diff
@@ -332,6 +332,36 @@ void() FoundTarget =
|
|||||||
HuntTarget ();
|
HuntTarget ();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//escorting
|
||||||
|
// ------------------------------------------------
|
||||||
|
float() FindMonster =
|
||||||
|
// ------------------------------------------------
|
||||||
|
{
|
||||||
|
local entity beast;
|
||||||
|
|
||||||
|
if (self.attack_state != ESCORTING)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (self.enemy)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
beast = findradius(self.origin, 1500);
|
||||||
|
|
||||||
|
while(beast)
|
||||||
|
{
|
||||||
|
if ( (beast.flags & FL_MONSTER) && visible(beast) && beast != self && beast.health > 0)
|
||||||
|
self.enemy = beast;
|
||||||
|
beast = beast.chain;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!self.enemy)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
FoundTarget();
|
||||||
|
return TRUE;
|
||||||
|
};
|
||||||
|
//
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===========
|
===========
|
||||||
FindTarget
|
FindTarget
|
||||||
@@ -354,6 +384,10 @@ float() FindTarget =
|
|||||||
local entity client;
|
local entity client;
|
||||||
local float r;
|
local float r;
|
||||||
|
|
||||||
|
// escorting
|
||||||
|
if (FindMonster())
|
||||||
|
return TRUE;
|
||||||
|
//
|
||||||
// if the first spawnflag bit is set, the monster will only wake up on
|
// if the first spawnflag bit is set, the monster will only wake up on
|
||||||
// really seeing the player, not another monster getting angry
|
// really seeing the player, not another monster getting angry
|
||||||
|
|
||||||
@@ -399,6 +433,20 @@ float() FindTarget =
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set escort state for monster_demon
|
||||||
|
// https://www.quaddicted.com/webarchive/minion.planetquake.gamespy.com/tutorial/tutor8.htm
|
||||||
|
|
||||||
|
if (self.attack_state == ESCORTING)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (self.classname == "monster_demon1")
|
||||||
|
{
|
||||||
|
self.goalentity = client;
|
||||||
|
self.attack_state = ESCORTING;
|
||||||
|
self.th_walk();
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// got one
|
// got one
|
||||||
//
|
//
|
||||||
@@ -487,6 +535,14 @@ void(float dist) ai_walk =
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
movetogoal (dist);
|
movetogoal (dist);
|
||||||
|
|
||||||
|
// escorting
|
||||||
|
if (self.attack_state == ESCORTING && vlen(self.origin - self.goalentity.origin) < 80)
|
||||||
|
{
|
||||||
|
self.pausetime = time + 3;
|
||||||
|
self.th_stand();
|
||||||
|
}
|
||||||
|
//
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1143,8 +1143,6 @@ void() PlayerPostThink =
|
|||||||
self.jump_flag = self.velocity_z;
|
self.jump_flag = self.velocity_z;
|
||||||
|
|
||||||
CheckPowerups ();
|
CheckPowerups ();
|
||||||
if (time < 5)
|
|
||||||
centerprint(self, "This is my first Quake mod!\n");
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -690,4 +690,4 @@ float (entity e, float healamount, float ignore) T_Heal; // health function
|
|||||||
|
|
||||||
float(entity targ, entity inflictor) CanDamage;
|
float(entity targ, entity inflictor) CanDamage;
|
||||||
|
|
||||||
|
float ESCORTING = 5;
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
674
tb/LICENSE.txt
Normal file
674
tb/LICENSE.txt
Normal file
@@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||||
16
tb/copyright
Normal file
16
tb/copyright
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
Copyright (C) 2010-2014 Kristian Duske
|
||||||
|
|
||||||
|
This file is part of TrenchBroom.
|
||||||
|
|
||||||
|
TrenchBroom is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
TrenchBroom is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
|
||||||
231
tb/games/DigitalPaintball2/GameConfig.cfg
Normal file
231
tb/games/DigitalPaintball2/GameConfig.cfg
Normal file
@@ -0,0 +1,231 @@
|
|||||||
|
{
|
||||||
|
"version": 3,
|
||||||
|
"name": "Digital Paintball2",
|
||||||
|
"icon": "Icon.png",
|
||||||
|
"fileformats": [ { "format": "Quake2" } ],
|
||||||
|
"filesystem": {
|
||||||
|
"searchpath": "pball",
|
||||||
|
"packageformat": { "extension": "pak", "format": "idpak" }
|
||||||
|
},
|
||||||
|
"textures": {
|
||||||
|
"package": { "type": "directory", "root": "textures" },
|
||||||
|
"format": { "extensions": [ "jpg", "png", "tga" ], "format": "image" },
|
||||||
|
"palette": "pics/colormap.pcx",
|
||||||
|
"attribute": "_tb_textures"
|
||||||
|
},
|
||||||
|
"entities": {
|
||||||
|
"definitions": [ "pball2.fgd" ],
|
||||||
|
"defaultcolor": "0.6 0.6 0.6 1.0",
|
||||||
|
"modelformats": [ "md2" ]
|
||||||
|
},
|
||||||
|
"tags": {
|
||||||
|
"brush": [
|
||||||
|
{
|
||||||
|
"name": "test2",
|
||||||
|
"attribs": [ "transparent" ],
|
||||||
|
"match": "classname",
|
||||||
|
"pattern": "trigger*",
|
||||||
|
"texture": "trigger"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"brushface": [
|
||||||
|
{
|
||||||
|
"name": "Trigger",
|
||||||
|
"attribs": [ "transparent" ],
|
||||||
|
"match": "texture",
|
||||||
|
"pattern": "trigger"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Clip",
|
||||||
|
"attribs": [ "transparent" ],
|
||||||
|
"match": "texture",
|
||||||
|
"pattern": "clip"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Skip",
|
||||||
|
"attribs": [ "transparent" ],
|
||||||
|
"match": "texture",
|
||||||
|
"pattern": "skip"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Hint",
|
||||||
|
"attribs": [ "transparent" ],
|
||||||
|
"match": "texture",
|
||||||
|
"pattern": "hint*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "glass",
|
||||||
|
"attribs": [ "transparent" ],
|
||||||
|
"match": "texture",
|
||||||
|
"pattern": "*glass*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "window",
|
||||||
|
"attribs": [ "transparent" ],
|
||||||
|
"match": "texture",
|
||||||
|
"pattern": "*window*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "trans",
|
||||||
|
"attribs": [ "transparent" ],
|
||||||
|
"match": "surfaceflag",
|
||||||
|
"flags": [ "trans33", "trans66" ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Detail",
|
||||||
|
"match": "contentflag",
|
||||||
|
"flags": [ "detail" ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Liquid",
|
||||||
|
"match": "contentflag",
|
||||||
|
"flags": [ "lava", "slime", "water" ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "nodraw",
|
||||||
|
"attribs": [ "transparent" ],
|
||||||
|
"match": "texture",
|
||||||
|
"pattern": "hint*"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"faceattribs": {
|
||||||
|
"surfaceflags": [
|
||||||
|
{
|
||||||
|
"name": "light",
|
||||||
|
"description": "Emit light from the surface, brightness is specified in the 'value' field"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "slick",
|
||||||
|
"description": "The surface is slippery"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sky",
|
||||||
|
"description": "The surface is sky, the texture will not be drawn, but the background sky box is used instead"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "warp",
|
||||||
|
"description": "The surface warps (like water textures do)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "trans33",
|
||||||
|
"description": "The surface is 33% transparent"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "trans66",
|
||||||
|
"description": "The surface is 66% transparent"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "flowing",
|
||||||
|
"description": "The texture wraps in a downward 'flowing' pattern (warp must also be set)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "nodraw",
|
||||||
|
"description": "Used for non-fixed-size brush triggers and clip brushes"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "hint",
|
||||||
|
"description": "Make a primary bsp splitter"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "skip",
|
||||||
|
"description": "Completely ignore, allowing non-closed brushes"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"contentflags": [
|
||||||
|
{
|
||||||
|
"name": "solid",
|
||||||
|
"description": "Default for all brushes"
|
||||||
|
}, // 1 << 0
|
||||||
|
{
|
||||||
|
"name": "window",
|
||||||
|
"description": "Brush is a window (not really used)"
|
||||||
|
}, // 1 << 1
|
||||||
|
{
|
||||||
|
"name": "aux",
|
||||||
|
"description": "Unused by the engine"
|
||||||
|
}, // 1 << 2
|
||||||
|
{
|
||||||
|
"name": "lava",
|
||||||
|
"description": "The brush is lava"
|
||||||
|
}, // 1 << 3
|
||||||
|
{
|
||||||
|
"name": "slime",
|
||||||
|
"description": "The brush is slime"
|
||||||
|
}, // 1 << 4
|
||||||
|
{
|
||||||
|
"name": "water",
|
||||||
|
"description": "The brush is water"
|
||||||
|
}, // 1 << 5
|
||||||
|
{
|
||||||
|
"name": "mist",
|
||||||
|
"description": "The brush is non-solid"
|
||||||
|
}, // 1 << 6
|
||||||
|
{ "name": "unused" }, // 1 << 7
|
||||||
|
{ "name": "unused" }, // 1 << 8
|
||||||
|
{ "name": "unused" }, // 1 << 9
|
||||||
|
{ "name": "unused" }, // 1 << 10
|
||||||
|
{ "name": "unused" }, // 1 << 11
|
||||||
|
{ "name": "unused" }, // 1 << 12
|
||||||
|
{ "name": "unused" }, // 1 << 13
|
||||||
|
{ "name": "unused" }, // 1 << 14
|
||||||
|
{ "name": "unused" }, // 1 << 15
|
||||||
|
{
|
||||||
|
"name": "playerclip",
|
||||||
|
"description": "Player cannot pass through the brush (other things can)"
|
||||||
|
}, // 1 << 16
|
||||||
|
{
|
||||||
|
"name": "mosterclip",
|
||||||
|
"description": "Monster cannot pass through the brush (player and other things can)"
|
||||||
|
}, // 1 << 17
|
||||||
|
{
|
||||||
|
"name": "current_0",
|
||||||
|
"description": "Brush has a current in direction of 0 degrees"
|
||||||
|
}, // 1 << 18
|
||||||
|
{
|
||||||
|
"name": "current_90",
|
||||||
|
"description": "Brush has a current in direction of 90 degrees"
|
||||||
|
}, // 1 << 19
|
||||||
|
{
|
||||||
|
"name": "current_180",
|
||||||
|
"description": "Brush has a current in direction of 180 degrees"
|
||||||
|
}, // 1 << 20
|
||||||
|
{
|
||||||
|
"name": "current_270",
|
||||||
|
"description": "Brush has a current in direction of 270 degrees"
|
||||||
|
}, // 1 << 21
|
||||||
|
{
|
||||||
|
"name": "current_up",
|
||||||
|
"description": "Brush has a current in the up direction"
|
||||||
|
}, // 1 << 22
|
||||||
|
{
|
||||||
|
"name": "current_dn",
|
||||||
|
"description": "Brush has a current in the down direction"
|
||||||
|
}, // 1 << 23
|
||||||
|
{
|
||||||
|
"name": "origin",
|
||||||
|
"description": "Special brush used for specifying origin of rotation for rotating brushes"
|
||||||
|
}, // 1 << 24
|
||||||
|
{
|
||||||
|
"name": "monster",
|
||||||
|
"description": "Purpose unknown"
|
||||||
|
}, // 1 << 25
|
||||||
|
{
|
||||||
|
"name": "corpse",
|
||||||
|
"description": "Purpose unknown"
|
||||||
|
}, // 1 << 26
|
||||||
|
{
|
||||||
|
"name": "detail",
|
||||||
|
"description": "Detail brush"
|
||||||
|
}, // 1 << 27
|
||||||
|
{
|
||||||
|
"name": "translucent",
|
||||||
|
"description": "Use for opaque water that does not block vis"
|
||||||
|
}, // 1 << 28
|
||||||
|
{
|
||||||
|
"name": "ladder",
|
||||||
|
"description": "Brushes with this flag allow a player to move up and down a vertical surface"
|
||||||
|
} // 1 << 29
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
tb/games/DigitalPaintball2/Icon.png
Normal file
BIN
tb/games/DigitalPaintball2/Icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
806
tb/games/DigitalPaintball2/pball2.fgd
Normal file
806
tb/games/DigitalPaintball2/pball2.fgd
Normal file
@@ -0,0 +1,806 @@
|
|||||||
|
// Paintball2 Entities - http://www.digitalpaint.org/
|
||||||
|
// Ported from pb2ents_b41.c by sort 3/18/2019
|
||||||
|
// Merged with original pball2.fgd and added spawnflags. 3/23/2019
|
||||||
|
// TB addon changes 20190403 - xaGe
|
||||||
|
|
||||||
|
@baseclass = AppearFlags [
|
||||||
|
spawnflags(Flags) =
|
||||||
|
[
|
||||||
|
256 : "Not in Easy" : 0
|
||||||
|
512 : "Not in Normal" : 0
|
||||||
|
1024 : "Not in Hard" : 0
|
||||||
|
2048 : "Not in Deathmatch" : 0
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
@BaseClass = Target
|
||||||
|
[
|
||||||
|
target(string) : "sets the target to a func_areaportal or target_speaker with the same targetname"
|
||||||
|
]
|
||||||
|
@BaseClass = TargetName
|
||||||
|
[
|
||||||
|
targetname(string) : "sets the target from a func_button, func_timer, etc. with the same target"
|
||||||
|
]
|
||||||
|
@BaseClass = TeamNumber
|
||||||
|
[
|
||||||
|
teamnumber(integer) : "sets the team for the base."
|
||||||
|
]
|
||||||
|
@BaseClass = Angle
|
||||||
|
[
|
||||||
|
angle(string) : "sets the direction the entity faces when spawning. 0 = right (East), 90 = up (North), 180 = left (West), 270 = down (South)."
|
||||||
|
]
|
||||||
|
@BaseClass base(AppearFlags) = Group
|
||||||
|
[
|
||||||
|
group(string) : "sets a group where randomly spawned guns will be the same"
|
||||||
|
]
|
||||||
|
|
||||||
|
@SolidClass = worldspawn : "World entity"
|
||||||
|
[
|
||||||
|
gamemode(Flags) =
|
||||||
|
[
|
||||||
|
1 : "Deathmatch" : 0
|
||||||
|
2 : "Single flag CTF" : 0
|
||||||
|
4 : "CTF" : 0
|
||||||
|
8 : "Siege" : 0
|
||||||
|
16 : "KOTH" : 0
|
||||||
|
64 : "Pong" : 0
|
||||||
|
]
|
||||||
|
maxteams(choices) : "sets the max number of teams supported in the map" =
|
||||||
|
[
|
||||||
|
2 : "for two teams"
|
||||||
|
3 : "for three teams"
|
||||||
|
4 : "for four teams"
|
||||||
|
]
|
||||||
|
team1(choices) : "sets the color for team 1." =
|
||||||
|
[
|
||||||
|
"red" : "red"
|
||||||
|
"blue" : "blue"
|
||||||
|
"yellow" : "yellow"
|
||||||
|
"purple" : "purple"
|
||||||
|
]
|
||||||
|
team2(choices) : "sets the color for team 2." =
|
||||||
|
[
|
||||||
|
"red" : "red"
|
||||||
|
"blue" : "blue"
|
||||||
|
"yellow" : "yellow"
|
||||||
|
"purple" : "purple"
|
||||||
|
]
|
||||||
|
team3(choices) : "sets the color for team 3." =
|
||||||
|
[
|
||||||
|
"red" : "red"
|
||||||
|
"blue" : "blue"
|
||||||
|
"yellow" : "yellow"
|
||||||
|
"purple" : "purple"
|
||||||
|
]
|
||||||
|
team4(choices) : "sets the color for team 4." =
|
||||||
|
[
|
||||||
|
"red" : "red"
|
||||||
|
"blue" : "blue"
|
||||||
|
"yellow" : "yellow"
|
||||||
|
"purple" : "purple"
|
||||||
|
]
|
||||||
|
message(string) : "sets a string while the map is loading."
|
||||||
|
sky(string) : "sets a sky to your sky brushes - <skyname> can be one of the following: unit1_, pbsky1, pbsky2, pbsky3, pbsky4, riverscape1, arctic1"
|
||||||
|
_sun_light(integer) : "arghrad - example: 250"
|
||||||
|
_sun_surface(integer) : "arghrad - brightness - A single brightness level. The color of the light is derived from the colors of all active suns, or the texture color if no suns are enabled. A value of 1 is special: it makes ArghRad use the surface`s own light value."
|
||||||
|
//_sun_surface(color255) : "arghrad - red green blue - Three separate brightness values for red, green, and blue lighting (normally not a standard RGB color). If all three values are 1 or less it has special meaning: it is treated like an RGB color:and the surface`s own light value is used."
|
||||||
|
_sun_color(string) : "arghrad - Sets the color of the sunlight to the specified rgb color value. If _sun_color is not specified, the color of the sky surface textures will be used instead."
|
||||||
|
_sun_diffuse(integer) : "arghrad - Sets the brightness of the diffused sunlight. This simulates the diffusion of light by atmospheric haze, creating a soft glow around the edges of sunlight shadows."
|
||||||
|
_sun_diffade(integer) : "arghrad - Scales how quickly the diffuse sunlight fades out over distance. The default distance is about 64 units. Values less than 1 fade slower, increasing the distance. Values greater than 1 fade faster, decreasing the distance. For example: a value of .5 fades half as fast, covering twice the distance, or about 128 units."
|
||||||
|
|
||||||
|
// Worldspawn Sun Aiming
|
||||||
|
// Like spotlights, there are several different methods available for setting the direction of suns in the Worldspawn. Choose any one of the methods that you prefer. Remember these point in the direction the sunlight is cast, not towards the sun. All suns points straight down by default.
|
||||||
|
_sun_angle(string) : "arghrad - Sets the sunlight direction by yaw and pitch angles. Yaw goes from 0-360 degrees around the z-axis, like the angle key. Pitch goes from -90 straight down, through 0 horizontal, to 90 straight up. def=0 -90"
|
||||||
|
_sun_target(string) : "arghrad - targetname: targetname of spotlight`s info_null. Sets the sunlight direction with separate light & info_null entities. Create and aim a spotlight using the traditional qrad3 info_null method. Then set the _sun_target value to the same targetname as the info_null. The sun will now point in the same direction as that spotlight."
|
||||||
|
_sun_vector(string) : "arghrad - Sets the sunlight direction by direction vector. This is the direction defined by a ray pointing from the origin (0 0 0) to the specified x y z value."
|
||||||
|
|
||||||
|
requiredfiles(string) : "sets paths for additional files required by the map (such as scripts) that do not download by default - <path> is the path to your file. Always use the forward slash. Keep filenames lowercase. Separate different pathes with a space.Example: 'requiredfiles' 'scripts/maps/mymap1.txt scripts/maps/mymap2.txt' for two of your own files"
|
||||||
|
forcejail(choices) : "forces eliminated players into jail spawns (no observer/ghosts)." =
|
||||||
|
[
|
||||||
|
0 : "no force jail"
|
||||||
|
1 : "force jail"
|
||||||
|
]
|
||||||
|
minclientbuild(integer) : "sets the minimum version a client must have to play the map (useful if you use advanced features)"
|
||||||
|
_ambient(integer) : "sets a general map ambient."
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
@SolidClass base(AppearFlags) = trigger_multiple : "Variable sized repeatable trigger. Must be targeted at one or more entities."
|
||||||
|
[
|
||||||
|
spawnflags(Flags) =
|
||||||
|
[
|
||||||
|
1 : "Monster" : 0
|
||||||
|
2 : "Not Player" : 0
|
||||||
|
4 : "Triggered" : 0
|
||||||
|
]
|
||||||
|
target(target_destination) : "sets the target to any other entities with the same targetname"
|
||||||
|
message(string) : "sets a string to be displayed when triggered"
|
||||||
|
delay(integer) : "sets a delay before first firing when turned on (0 default)."
|
||||||
|
wait(integer) : "sets the seconds between triggerings (2 default)."
|
||||||
|
sounds(choices) : "sets a sound to be played when triggered" =
|
||||||
|
[
|
||||||
|
1 : "secret"
|
||||||
|
2 : "beep beep"
|
||||||
|
3 : "large switch"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
@SolidClass base(AppearFlags, TeamNumber) = base : "Base trigger. A player must touch this while holding the flag to get points."
|
||||||
|
[
|
||||||
|
count(integer) : "sets a multiplier for the points scored when capturing. Default is 5, so if you want a flag captured at this base to only be worth 1 point, you can set 'count' '.2'"
|
||||||
|
]
|
||||||
|
|
||||||
|
@SolidClass base(AppearFlags) = hill : "Hill for gamemode KOTH. When a player touches the hill, their team gets points. A flag with no teamnumber is also suggested, so that it's easy to tell if somebody is on the hill (players can also get points by touching the flag itself)."
|
||||||
|
[
|
||||||
|
gamemode(integer) : "sets the gamemode (KOTH only, should always be 16)."
|
||||||
|
]
|
||||||
|
|
||||||
|
@SolidClass base(AppearFlags, TeamNumber) = func_teamwall : "Wall that exists only when the team has no players." []
|
||||||
|
|
||||||
|
@SolidClass base(AppearFlags) = func_dsm : "Dynamically Sizing Map entity. Apply this to brushes to seal off/open areas depending on the number of players present."
|
||||||
|
[
|
||||||
|
spawnflags(Flags) =
|
||||||
|
[
|
||||||
|
1 : "invert_behavior" : 0 : "closes off areas instead of open up when more players are present."
|
||||||
|
]
|
||||||
|
open_pcount_all(integer) : "if # or more players are in the game, the entity will disappear, opening a new path."
|
||||||
|
close_pcount_all(integer) : "if # or fewer players are present, the entity will reappear and close off the path."
|
||||||
|
]
|
||||||
|
|
||||||
|
@baseclass base(Appearflags, Targetname) size(-16 -16 -24, 16 16 32) color(0 255 0) = PlayerClass []
|
||||||
|
|
||||||
|
@PointClass base(PlayerClass) = info_player_start : "Player 1 start" []
|
||||||
|
@PointClass base(PlayerClass) = info_player_deathmatch : "Player deathmatch start"
|
||||||
|
[
|
||||||
|
teamnumber(integer) : "sets which team's players will spawn at this point. Setting to 0 means any team can spawn here."
|
||||||
|
givegun(choices) : "sets the type of the weapon the player starts with instead of the pgp" =
|
||||||
|
[
|
||||||
|
"trracer" : "for spawning a Trracer"
|
||||||
|
"stingray" : "for spawning a Stingray"
|
||||||
|
"vm68" : "for spawning a VM-68"
|
||||||
|
"carbine" : "for spawning a 68 Carbine"
|
||||||
|
"spyder" : "for spawning a Spyder SE"
|
||||||
|
"autococker" : "for spawning an Autococker"
|
||||||
|
"automag" : "for spawning an Automag"
|
||||||
|
"low" : "for randomly spawning a Trracer or Stingray"
|
||||||
|
"medium" : "for randomly spawning a VM-68, 68 Carbine or Spyder SE"
|
||||||
|
"high" : "for randomly spawning an Autococker or Automag"
|
||||||
|
]
|
||||||
|
givehopper(choices) : "sets the type of the hopper the player starts with" =
|
||||||
|
[
|
||||||
|
100 : "for spawning a hopper of 100"
|
||||||
|
200 : "for spawning a hopper of 200"
|
||||||
|
]
|
||||||
|
giveammo(choices) : "sets the type of the ammo pack the player starts with" =
|
||||||
|
[
|
||||||
|
"25" : "for spawning an ammo pack of 25"
|
||||||
|
"50" : "for spawning an ammo pack of 50"
|
||||||
|
"100" : "for spawning an ammo pack of 100"
|
||||||
|
"150" : "for spawning an ammo pack of 150"
|
||||||
|
"200" : "for spawning an ammo pack of 200"
|
||||||
|
"small" : "for randomly spawning an ammo pack of 25, 50 or 100"
|
||||||
|
"medium" : "for randomly spawning an ammo pack of 50, 100 or 150"
|
||||||
|
"large" : "for randomly spawning an ammo pack of 100, 150 or 200"
|
||||||
|
]
|
||||||
|
givebarrel(choices) : "sets the type of the barrel the player starts with" =
|
||||||
|
[
|
||||||
|
"brass" : "for a brass barrel"
|
||||||
|
"chrome" : "for a chrome barrel"
|
||||||
|
"steel" : "for a steel barrel"
|
||||||
|
]
|
||||||
|
giveco2(choices) : "sets the type of the co2 tank the player starts with" =
|
||||||
|
[
|
||||||
|
"12g" : "for spawning a co2 tank of 12g"
|
||||||
|
"7oz" : "for spawning a co2 tank of 7oz"
|
||||||
|
"12oz" : "for spawning a co2 tank of 12oz"
|
||||||
|
"20oz" : "for spawning a co2 tank of 20oz"
|
||||||
|
"small" : "for randomly spawning a co2 tank of 12g or 7oz"
|
||||||
|
"medium" : "for randomly spawning a co2 tank of 7oz or 12oz"
|
||||||
|
"large" : "for randomly spawning a co2 tank of 12oz or 20oz"
|
||||||
|
]
|
||||||
|
loadedco2(choices) : "sets the type of the loaded co2 the player starts with" =
|
||||||
|
[
|
||||||
|
"12g" : "for spawning a co2 tank of 12g"
|
||||||
|
"7oz" : "for spawning a co2 tank of 7oz"
|
||||||
|
"12oz" : "for spawning a co2 tank of 12oz"
|
||||||
|
"20oz" : "for spawning a co2 tank of 20oz"
|
||||||
|
"small" : "for randomly spawning a co2 tank of 12g or 7oz"
|
||||||
|
"medium" : "for randomly spawning a co2 tank of 7oz or 12oz"
|
||||||
|
"large" : "for randomly spawning a co2 tank of 12oz or 20oz"
|
||||||
|
]
|
||||||
|
jail(integer) : "set to 1 to make it a jail spawn for eliminated players."
|
||||||
|
]
|
||||||
|
@PointClass base(AppearFlags, Angle) size(-8 -8 -8, 8 8 8) studio({ "path" : model, "skin" : skin, "frame" : frame}) = func_model : "Places a model in the map. Not affected by gravity.Example: 'model' 'models/items/ammo/tris.md2' for the plant model seen in several maps (Pay attention of additional files required by the model.) Add 'requiredfiles' '<path>' to the worldspawn if necessary."
|
||||||
|
[
|
||||||
|
model(string) : "sets what model to use - <modelpath> `models/items/ammo/tris.md2` can be the path of available or your added models"
|
||||||
|
//skin(string) : "sets what skin # to use - example `3` skin selection defaults to `0` of available or your added models"
|
||||||
|
//frame(string) : "sets what frame # to use - example `2` can be the frame of available or your added models"
|
||||||
|
]
|
||||||
|
|
||||||
|
@PointClass base(Group) size(-8 -8 6, 8 8 26) studio({{
|
||||||
|
type == "paint" -> {"path":"models/items/grenades/paint/ground.md2", "skin": 0},
|
||||||
|
type == "smoke" -> {"path":"models/items/grenades/smoke/ground.md2", "skin": 0},
|
||||||
|
"models/items/grenades/paint/ground.md2"
|
||||||
|
}}) = item_pballgrenade : "Spawning spot for grenades. If no type is specified, the grenade will be random."
|
||||||
|
[
|
||||||
|
type(choices) : "set the type of the grenade" =
|
||||||
|
[
|
||||||
|
"paint" : "for a paint grenade"
|
||||||
|
"smoke" : "for a smoke grenade"
|
||||||
|
]
|
||||||
|
angle(string) : "-1 sets that the grenade will spawn exactly where you placed the entity and not somewhere in the area."
|
||||||
|
count(integer) : "1 sets that grenades always spawn there in addition to the number of grenades set by the server."
|
||||||
|
]
|
||||||
|
|
||||||
|
// xaGe
|
||||||
|
@PointClass base(Group) color(80 80 255) size(-32 -32 -4, 32 32 28) studio({{
|
||||||
|
type == "autococker" -> {"path":"models/weapons/g_autoc/tris.md2"},
|
||||||
|
type == "automag" -> {"path":"models/weapons/g_autom/tris.md2"},
|
||||||
|
type == "carbine" -> {"path":"models/weapons/g_68carbine/tris.md2"},
|
||||||
|
type == "high" -> {"path":"models/weapons/g_autoc/tris.md2"},
|
||||||
|
type == "low" -> {"path":"models/weapons/g_trrac/tris.md2"},
|
||||||
|
type == "medium" -> {"path":"models/weapons/g_vm68/tris.md2"},
|
||||||
|
type == "spyder" -> {"path":"models/weapons/g_spyder/tris.md2"},
|
||||||
|
type == "stingray" -> {"path":"models/weapons/g_sting/tris.md2"},
|
||||||
|
type == "trracer" -> {"path":"models/weapons/g_trrac/tris.md2"},
|
||||||
|
type == "vm68" -> {"path":"models/weapons/g_vm68/tris.md2"},
|
||||||
|
"models/weapons/g_vm68/tris.md2"
|
||||||
|
}}) = weapon_pballgun :
|
||||||
|
|
||||||
|
"Spawning spot for guns. If no type is specified, the gun will be random.
|
||||||
|
|
||||||
|
autococker : Spawns an Autococker
|
||||||
|
automag : Spawns an Automag
|
||||||
|
carbine : Spawns a 68 Carbine
|
||||||
|
high : Randomly spawns either an Autococker or Automag
|
||||||
|
low : Randomly spawns a Trracer or Stingray
|
||||||
|
medium : Randomly spawns a VM-68, 68 Carbine or Spyder SE
|
||||||
|
spyder : Spawns a Spyder SE
|
||||||
|
stingray : Spawns a Stingray
|
||||||
|
trracer : Spawns a Trracer
|
||||||
|
vm68 : Spawns a VM-68"
|
||||||
|
[
|
||||||
|
type(choices) : "sets the type of the weapon" =
|
||||||
|
[
|
||||||
|
"autococker" : "for spawning an Autococker"
|
||||||
|
"automag" : "for spawning an Automag"
|
||||||
|
"carbine" : "for spawning a 68 Carbine"
|
||||||
|
"high" : "for randomly spawning an Autococker or Automag"
|
||||||
|
"low" : "for randomly spawning a Trracer or Stingray"
|
||||||
|
"medium" : "for randomly spawning a VM-68, 68 Carbine or Spyder SE"
|
||||||
|
"spyder" : "for spawning a Spyder SE"
|
||||||
|
"stingray" : "for spawning a Stingray"
|
||||||
|
"trracer" : "for spawning a Trracer"
|
||||||
|
"vm68" : "for spawning a VM-68"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
@PointClass base(Group) color(200 0 200) size(-8 -8 16, 8 8 32) studio({{
|
||||||
|
type == 100 -> {"path":"models/items/hopper/tris.md2", "skin": 0},
|
||||||
|
type == 200 -> {"path":"models/items/hopper/tris.md2", "skin": 1},
|
||||||
|
"models/items/hopper/tris.md2"
|
||||||
|
}}) = item_pballhopper :
|
||||||
|
|
||||||
|
"Spawning spot for hoppers. If no type is specified, the hopper will be random."
|
||||||
|
[
|
||||||
|
type(choices) : "sets the type of the hopper" =
|
||||||
|
[
|
||||||
|
100 : "for spawning a hopper of 100"
|
||||||
|
200 : "for spawning a hopper of 200"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
@PointClass base(AppearFlags) color(200 128 25) size(-12 -12 0, 12 12 8) studio({{
|
||||||
|
type == "25" -> {"path":"models/items/ammo/tris.md2", "skin": 0, "frame": 0},
|
||||||
|
type == "50" -> {"path":"models/items/ammo/tris.md2", "skin": 1, "frame": 1},
|
||||||
|
type == "100" -> {"path":"models/items/ammo/tris.md2", "skin": 2, "frame": 2},
|
||||||
|
type == "150" -> {"path":"models/items/ammo/tris.md2", "skin": 3, "frame": 3},
|
||||||
|
type == "200" -> {"path":"models/items/ammo/tris.md2", "skin": 4, "frame": 4},
|
||||||
|
type == "small" -> {"path":"models/items/ammo/tris.md2", "skin": 0, "frame": 0},
|
||||||
|
type == "medium" -> {"path":"models/items/ammo/tris.md2", "skin": 2, "frame": 2},
|
||||||
|
type == "large" -> {"path":"models/items/ammo/tris.md2", "skin": 3, "frame": 3},
|
||||||
|
"models/items/ammo/tris.md2"
|
||||||
|
}}) = item_pballammo : "Spawning spot for ammo. If no type is specified, the ammo will be random."
|
||||||
|
[
|
||||||
|
type(choices) : "sets the type of the ammo pack" =
|
||||||
|
[
|
||||||
|
"25" : "for spawning an ammo pack of 25"
|
||||||
|
"50" : "for spawning an ammo pack of 50"
|
||||||
|
"100" : "for spawning an ammo pack of 100"
|
||||||
|
"150" : "for spawning an ammo pack of 150"
|
||||||
|
"200" : "for spawning an ammo pack of 200"
|
||||||
|
"small" : "for randomly spawning an ammo pack of 25, 50 or 100"
|
||||||
|
"medium" : "for randomly spawning an ammo pack of 50, 100 or 150"
|
||||||
|
"large" : "for randomly spawning an ammo pack of 100, 150 or 200"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
@PointClass base(Group) color(200 0 0) size(-4 -4 12, 4 4 32) studio({{
|
||||||
|
type == "12g" -> {"path":"models/items/co2/12g/tris.md2", "skin": 0},
|
||||||
|
type == "7oz" -> {"path":"models/items/co2/7oz/tris.md2", "skin": 0},
|
||||||
|
type == "12oz" -> {"path":"models/items/co2/12oz/tris.md2", "skin": 0},
|
||||||
|
type == "20oz" -> {"path":"models/items/co2/20oz/tris.md2", "skin": 0},
|
||||||
|
type == "small" -> {"path":"models/items/co2/12g/tris.md2", "skin": 0},
|
||||||
|
type == "medium" -> {"path":"models/items/co2/7oz/tris.md2", "skin": 0},
|
||||||
|
type == "large" -> {"path":"models/items/co2/12oz/tris.md2", "skin": 0},
|
||||||
|
"models/items/co2/7oz/tris.md2"
|
||||||
|
}}) = item_pballco2 : "Spawning spot for co2. If no type is specified, the co2 will be random."
|
||||||
|
[
|
||||||
|
type(choices) : "sets the type of the co2 tank" =
|
||||||
|
[
|
||||||
|
"12g" : "for spawning a co2 tank of 12g"
|
||||||
|
"7oz" : "for spawning a co2 tank of 7oz"
|
||||||
|
"12oz" : "for spawning a co2 tank of 12oz"
|
||||||
|
"20oz" : "for spawning a co2 tank of 20oz"
|
||||||
|
"small" : "for randomly spawning a co2 tank of 12g or 7oz"
|
||||||
|
"medium" : "for randomly spawning a co2 tank of 7oz or 12oz"
|
||||||
|
"large" : "for randomly spawning a co2 tank of 12oz or 20oz"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
@PointClass base(Group) color(200 200 0) size(-12 -12 24, 12 12 40) studio({{
|
||||||
|
type == "brass" -> {"path":"models/items/barrel/tris.md2", "skin": 2},
|
||||||
|
type == "chrome" -> {"path":"models/items/barrel/tris.md2", "skin": 1},
|
||||||
|
type == "steel" -> {"path":"models/items/barrel/tris.md2", "skin": 0},
|
||||||
|
"models/items/barrel/tris.md2"
|
||||||
|
}}) = item_pballbarrel : "Spawning spot for barrels. If no type is specified, the barrel will be random."
|
||||||
|
[
|
||||||
|
type(choices) : "sets the type of the barrel" =
|
||||||
|
[
|
||||||
|
"brass" : "for a brass barrel"
|
||||||
|
"chrome" : "for a chrome barrel"
|
||||||
|
"steel" : "for a steel barrel"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PointClass base(AppearFlags, TeamNumber) color(0 255 255) size(-8 -16 -16, 8 16 48) studio({"path": "models/items/flag/tris.md2"}) = flag : ""
|
||||||
|
[
|
||||||
|
count(integer) : "
|
||||||
|
0.2 - for a flag with one point
|
||||||
|
0.4 - for a flag with two points
|
||||||
|
0.6 - for a flag with three points
|
||||||
|
0.8 - for a flag with four points
|
||||||
|
1.0 - for a flag with five points
|
||||||
|
1.2 - for a flag with six points
|
||||||
|
1.4 - for a flag with seven points
|
||||||
|
1.6 - for a flag with eight points
|
||||||
|
1.8 - for a flag with nine points
|
||||||
|
2.0 - for a flag with ten points"
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@SolidClass = func_group : "Used to group brushes together just for editor convenience." []
|
||||||
|
|
||||||
|
@SolidClass = func_areaportal : "This is a non-visible object that divides the world into areas that are seperated when this portal is not activated. Usually enclosed in the middle of a door. This can help performance by not rendering areas that are behind closed doors.Must be targeted." []
|
||||||
|
|
||||||
|
@PointClass base(AppearFlags) color(128 80 0) size(-8 -8 -8, 8 8 8) = path_corner : "Set the direction of func_trains etc. Target it to the next path corner."
|
||||||
|
[
|
||||||
|
targetname(string) : "sets the target from the previous path_corner entity with the same target"
|
||||||
|
target(string) : "sets the target to the next path_corner entity with the same targetname"
|
||||||
|
]
|
||||||
|
|
||||||
|
@PointClass base(AppearFlags) color(0 128 0) size(-4 -4 -4, 4 4 4) = info_null : "Used as a positional target for spotlights, etc."
|
||||||
|
[
|
||||||
|
targetname(string) : "sets the target from the light source with the same target"
|
||||||
|
]
|
||||||
|
|
||||||
|
@PointClass base(AppearFlags) color(0 128 0) size(-4 -4 -4, 4 4 4) = info_notnull : "Used as a positional target jump pads, etc."
|
||||||
|
[
|
||||||
|
targetname(string) : "sets the target from the trigger_push with the same target"
|
||||||
|
]
|
||||||
|
|
||||||
|
@PointClass base(AppearFlags) color(0 255 0) size(-8 -8 -8, 8 8 8) = light : "Point light with no visible source. Only applies lighting to the world."
|
||||||
|
[
|
||||||
|
light(integer) : "sets the light power (300 default)."
|
||||||
|
style(integer) : "sets the light style (0 default)."
|
||||||
|
_color(color255) : "sets the light color (0 default). Example 255 255 255"
|
||||||
|
target(string) : "sets the target for spotlights to the info_null entity with the same targetname."
|
||||||
|
_cone(integer) : "sets the size of light for spotlights (10 default)"
|
||||||
|
//Light Attenuation
|
||||||
|
_angfade(integer) : "arghrad - Scales how quickly the light fades as the angle-of-incidence decreases (from perpendicular to parallel). Values less than 1 fade slower, so the angle has less affect. Values greater than 1 fade faster, so the angle has more pronounced affect. def = 1 - This AKA _angwait"
|
||||||
|
_bounce(integer) : "arghrad - 0 (no bounce) or 1 (bounce) default: 1. A value of 0 allows this light entity to be completely excluded from the bounced light calculations."
|
||||||
|
_cap(integer) : "arghrad - Caps the lighting cast from this light to the specified brightness level. The lighting is calculated normally, then any brighter points are capped off."
|
||||||
|
_distance(integer) : "arghrad - Sets the maximum distance that light shines from this entity. Behavior varies depending on the light`s _falloff setting:
|
||||||
|
|
||||||
|
-Linear falloff - Smoothly fades out from the light to the specified distance. This overrides the _fade setting.
|
||||||
|
|
||||||
|
-Inverse & inverse-square falloff - Sets a cutoff distance where the light abruptly stops shining."
|
||||||
|
_fade(integer) : "arghrad - Scales how quickly the light fades over distance. Values less than 1 fade slower, increasing the distance. Values greater than 1 fade faster, decreasing the distance. For example, a value of .5 fades half as fast, shining twice as far. PLEASE Note: This setting only works on lights with linear falloff."
|
||||||
|
_falloff(string) : "arghrad - Sets the falloff formula for this light entity. A value of 0 sets linear falloff, the default. A value of 2 sets inverse-square falloff, like surface lights.
|
||||||
|
|
||||||
|
A value of 1 sets inverse falloff: lighting = brightness / distance. At 2 units away the light would be 1/2 as bright, at 3 units it's 1/3, etc. This can work very well for visible-sourced point-lights (mine-lights, torches, etc). It's more realistic than linear falloff, but not as `severe` as inverse-square.
|
||||||
|
|
||||||
|
Note: Inverse and inverse-square falloff require much higher brightness values than linear."
|
||||||
|
]
|
||||||
|
|
||||||
|
@SolidClass base(AppearFlags) color(0 128 200) = func_wall : "This is just a solid wall if not inhibited."
|
||||||
|
[
|
||||||
|
spawnflags(Flags) =
|
||||||
|
[
|
||||||
|
1 : "trigger_spawn" : 0 : "the wall will not be present until triggered, it will then blink in to existance; it will kill anything that was in it's way."
|
||||||
|
2 : "toggle" : 0 : "only valid for TRIGGER_SPAWN walls, this allows the wall to be turned on and off."
|
||||||
|
4 : "start_on" : 0 : "only valid for TRIGGER_SPAWN walls, the wall will initially be present."
|
||||||
|
8 : "animated" : 0
|
||||||
|
16 : "animated_fast" : 0
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
@SolidClass base(AppearFlags) = func_object : "This is solid bmodel that will fall if it's support is removed."
|
||||||
|
[
|
||||||
|
spawnflags(Flags) =
|
||||||
|
[
|
||||||
|
1 : "trigger_spawn" : 0 : "the wall will not be present until triggered, it will then blink in to existance; it will kill anything that was in it's way."
|
||||||
|
2 : "animated" : 0
|
||||||
|
4 : "animated_fast" : 0
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
@SolidClass base(AppearFlags) color(0 0 255) = target_character : "Used with target_string (must be on same 'team')"
|
||||||
|
[
|
||||||
|
count(integer) : "sets the position in the string (starts at 1)"
|
||||||
|
]
|
||||||
|
|
||||||
|
@PointClass base(AppearFlags) color(0 0 255) size(-8 -8 -8, 8 8 8) = target_string : "" []
|
||||||
|
|
||||||
|
@PointClass base(AppearFlags) color(0 0 255) size(-8 -8 -8, 8 8 8) = func_clock : "Target a target_string with this. The default is to be a time of day clock.TIMER_UP and TIMER_DOWN run for 'count' '#' seconds and the fire 'pathtarget' '<targetto>'If START_OFF, this entity must be used before it starts."
|
||||||
|
[
|
||||||
|
spawnflags(Flags) =
|
||||||
|
[
|
||||||
|
1 : "timer_up" : 0 : "run for 'count' '#' seconds and the fire 'pathtarget' '<targetto>' - <targetto> can be your own value."
|
||||||
|
2 : "timer_down" : 0 : "run for 'count' '#' seconds and the fire 'pathtarget' '<targetto>' - <targetto> can be your own value."
|
||||||
|
4 : "start_off" : 0 : "If START_OFF, this entity must be used before it starts."
|
||||||
|
8 : "multi_use" : 0
|
||||||
|
]
|
||||||
|
style(choices) : "clock style" =
|
||||||
|
[
|
||||||
|
0 : "for a style like xx"
|
||||||
|
1 : "for a style like xx:xx"
|
||||||
|
2 : "for a style like xx:xx:xx"
|
||||||
|
]
|
||||||
|
pathtarget(string) : "see timer_up and timer_down spawnflags."
|
||||||
|
]
|
||||||
|
|
||||||
|
@PointClass base(AppearFlags) color(255 0 0) size(-32 -32 -24, 32 32 -16) = misc_teleporter : "Touching this will teleport players to the targeted misc_teleporter_dest object."
|
||||||
|
[
|
||||||
|
target(string) : "sets the target to the misc_teleporter_dest entity with the same targetname"
|
||||||
|
]
|
||||||
|
|
||||||
|
@PointClass base(AppearFlags, Angle) color(255 0 0) size(-32 -32 -24, 32 32 -16) = misc_teleporter_dest : "Players who touched the 'misc_teleporter' will appear here."
|
||||||
|
[
|
||||||
|
targetname(string) : "sets the target from the misc_teleporter entity with the same target"
|
||||||
|
]
|
||||||
|
|
||||||
|
@PointClass base(AppearFlags) color(255 0 0) size(-8 -8 -8, 8 8 8) = target_temp_entity : "Fire an origin based temp entity event to the clients."
|
||||||
|
[
|
||||||
|
targetname(string) : "sets the target from a func_button, func_timer, etc. with the same target."
|
||||||
|
style(integer) : "5 - for a yellow explosion\r21 - for a blue explosion\r45 - for a smoke puff\r48 - for a cyllindrical explosion\r51 - for a large and fast spherical explosion\r52 - for a slow and smaller spherical explosion\rOther values may also work, but can also crash the game, so be careful what you use."
|
||||||
|
]
|
||||||
|
|
||||||
|
@PointClass base(AppearFlags) color(255 0 0) size(-8 -8 -8, 8 8 8) = target_speaker : "Normal sounds play each time the target is used."
|
||||||
|
[
|
||||||
|
targetname(string) : "sets the target from a func_button, func_timer, etc. with the same target"
|
||||||
|
noise(string) : "sets the .wav file to play - <soundpath> is the path to your file. Example: 'noise' 'world/cricket.wav'"
|
||||||
|
volume(float) : "sets the volume power - # options can be 0.0 to 1.0."
|
||||||
|
attenuation(choices) : "volume falloffLooped sounds are allways atten 3 / vol 1, and the use function toggles it on/off.The reliable flag can be set for very important sounds like crucial voiceovers." =
|
||||||
|
[
|
||||||
|
-1 : "for no falloff, send to whole level"
|
||||||
|
1 : "for normal fighting sounds"
|
||||||
|
2 : "for idle sound level"
|
||||||
|
3 : "for ambient sound level (very rapid falloff)"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
@PointClass base(AppearFlags) color(255 0 0) size(-8 -8 -8, 8 8 8) = target_changelevel : "Changes level when fired."
|
||||||
|
[
|
||||||
|
map(string) : "sets the level to change to."
|
||||||
|
]
|
||||||
|
|
||||||
|
@PointClass base(AppearFlags) color(255 0 0) size(-8 -8 -8, 8 8 8) = target_splash : "Creates a particle splash effect when used."
|
||||||
|
[
|
||||||
|
dmg(integer) : "sets a radius damage to inflict at this location when it splashes (useful for lava/sparks)"
|
||||||
|
count(integer) : "sets how many pixels are in the splash."
|
||||||
|
sounds(choices) : "sets a style (not a sound)" =
|
||||||
|
[
|
||||||
|
1 : "for sparks"
|
||||||
|
2 : "for blue water"
|
||||||
|
3 : "for brown water"
|
||||||
|
4 : "for slime"
|
||||||
|
5 : "for lava"
|
||||||
|
6 : "for blood"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
@PointClass base(AppearFlags) color(255 0 0) size(-8 -8 -8, 8 8 8) = target_spawner : "Set target to the type of entity you want spawned.Useful for spawning monsters and gibs in the factory levels.For monsters:Set direction to the facing you want it to have.For gibs:Set direction if you want it moving and speed how fast it should be moving otherwise it will just be dropped." []
|
||||||
|
|
||||||
|
@PointClass base(AppearFlags) color(0 128 200) size(-8 -8 -8, 8 8 8) = target_laser : "When triggered, fires a laser. You can either set a target or a direction."
|
||||||
|
[
|
||||||
|
spawnflags(Flags) =
|
||||||
|
[
|
||||||
|
1 : "start_on" : 0
|
||||||
|
2 : "red" : 0
|
||||||
|
4 : "green" : 0
|
||||||
|
8 : "blue" : 0
|
||||||
|
16 : "yellow" : 0
|
||||||
|
32 : "orange" : 0
|
||||||
|
64 : "fat" : 0
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
@PointClass base(AppearFlags) color(0 128 200) size(-8 -8 -8, 8 8 8) = target_lightramp : "Makes a light fade in or fade out."
|
||||||
|
[
|
||||||
|
spawnflags(Flags) =
|
||||||
|
[
|
||||||
|
1 : "toggle" : 0
|
||||||
|
]
|
||||||
|
targetname(string) : "sets the target from a func_button, func_timer, etc. with the same target."
|
||||||
|
target(string) : "sets the target to the light source with the same targetname."
|
||||||
|
speed(integer) : "sets how many seconds the ramping will take."
|
||||||
|
message(choices) : "sets the starting lightlevel and the ending lightlevel in two letters" =
|
||||||
|
[
|
||||||
|
"az" : "for a light that fades in from dark to light"
|
||||||
|
"za" : "for a light that fades in from light to dark"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
@SolidClass base(AppearFlags) = trigger_once : "Triggers once, then removes itself. Target it with any entity."
|
||||||
|
[
|
||||||
|
spawnflags(Flags) =
|
||||||
|
[
|
||||||
|
1 : "triggered" : 0 : "sets that this trigger must be triggered before it is live."
|
||||||
|
]
|
||||||
|
target(string) : "sets the target to any other entities with the same targetname."
|
||||||
|
message(string) : "sets a string to be displayed when triggered."
|
||||||
|
delay(integer) : "sets a delay before first firing when turned on (0 default)."
|
||||||
|
sounds(choices) : "sets a sound to be played when triggered" =
|
||||||
|
[
|
||||||
|
1 : "secret"
|
||||||
|
2 : "beep beep"
|
||||||
|
3 : "large switch"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
@PointClass base(AppearFlags) color(128 128 128) size(-8 -8 -8, 8 8 8) = trigger_relay : "This fixed size trigger cannot be touched, it can only be fired by other events." []
|
||||||
|
|
||||||
|
@SolidClass base(AppearFlags) = trigger_counter : "Acts as an intermediary for an action that takes multiple inputs.If nomessage is not set, it will print '1 more.. ' etc when triggered and 'sequence complete' when finished.After the counter has been triggered 'count' '#' times (default 2), it will fire all of it's targets and remove itself."
|
||||||
|
[
|
||||||
|
spawnflags(Flags) =
|
||||||
|
[
|
||||||
|
1 : "nomessage" : 0 : "If nomessage is not set, it will print '1 more.. ' etc when triggered and 'sequence complete' when finished. After the counter has been triggered 'count' '#' times (default 2), it will fire all of it's targets and remove itself."
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
@PointClass base(AppearFlags) color(128 128 128) size(-8 -8 -8, 8 8 8) = trigger_always : "This trigger will always fire. It is activated by the world."
|
||||||
|
[
|
||||||
|
target(string) : "sets the target to any other entities with the same targetname"
|
||||||
|
]
|
||||||
|
|
||||||
|
@SolidClass base(AppearFlags) = trigger_push : "Pushes players and grenades so they will hit the targeted info_notnull."
|
||||||
|
[
|
||||||
|
spawnflags(Flags) =
|
||||||
|
[
|
||||||
|
1 : "push_once" : 0 : "affects all entities (paint, guns, etc)."
|
||||||
|
2 : "push_all" : 0 : "causes the trigger_push to be removed after the first touch."
|
||||||
|
]
|
||||||
|
target(string) : "sets the target to the info_notnull entity with the same targetname"
|
||||||
|
]
|
||||||
|
|
||||||
|
@SolidClass base(AppearFlags) = trigger_hurt : "Any entity that touches this will be hurt."
|
||||||
|
[
|
||||||
|
spawnflags(Flags) =
|
||||||
|
[
|
||||||
|
1 : "start_off" : 0 : "when the trigger_hurt must be triggered by a func_button, func_timer, etc."
|
||||||
|
2 : "toggle" : 0 : "toggles this trigger between enabled and disabled states."
|
||||||
|
4 : "silent" : 0 : "supresses playing the sound."
|
||||||
|
8 : "no_protection" : 0 : "makes that nothing can stop the damage."
|
||||||
|
16 : "slow" : 0 : "changes the damage rate to once per second."
|
||||||
|
]
|
||||||
|
message(string) : "sets a string to be displayed when touched"
|
||||||
|
dmg(integer) : "sets a damage to inflict when touches (5 default)"
|
||||||
|
]
|
||||||
|
|
||||||
|
@SolidClass base(AppearFlags) = trigger_gravity : "Changes the touching entities gravity. Unfortunately, this does not work for players."
|
||||||
|
[
|
||||||
|
gravity(integer) : "sets the gravity value (1 default)."
|
||||||
|
]
|
||||||
|
|
||||||
|
@SolidClass base(AppearFlags) = func_getoutofjail : "Turns an eleminated player into a living player when touched."
|
||||||
|
[
|
||||||
|
noise(string) : "sets the .wav file to play"
|
||||||
|
]
|
||||||
|
|
||||||
|
@PointClass base(AppearFlags, Angle) color(255 0 0) size(-16 -16 -24, 16 16 40) = info_player_start : "Starting point for single player, which isn't really applicable here. Players will spawn here if there are no info_player_deathmatches." []
|
||||||
|
|
||||||
|
|
||||||
|
@PointClass base(AppearFlags) color(255 0 255) size(-16 -16 -24, 16 16 40) = info_player_intermission : "This is where the camera will be placed at the end of the match when the scoreboard is shown."
|
||||||
|
[
|
||||||
|
angles(string) : "# # # sets the direction (pitch-yaw-roll)"
|
||||||
|
]
|
||||||
|
|
||||||
|
@BaseClass base(AppearFlags) = Door
|
||||||
|
[
|
||||||
|
spawnflags(Flags) =
|
||||||
|
[
|
||||||
|
1 : "start_open" : 0 : "the door to moves to its destination when spawned and operate in reverse. It is used to temporarily or permanently close off an area when triggered (not useful for touch or takedamage doors)."
|
||||||
|
2 : "x" : 0 : ""
|
||||||
|
4 : "crusher" : 0 : "door will not move back if blocked."
|
||||||
|
8 : "nomonster" : 0 : ""
|
||||||
|
16 : "animated" : 0 : ""
|
||||||
|
32 : "toggle" : 0 : "wait in both the start and end states for a trigger event."
|
||||||
|
64 : "animated_fast" : 0 : ""
|
||||||
|
]
|
||||||
|
targetname(string) : "sets the target from a func_button, func_timer, etc. with the same target."
|
||||||
|
target(string) : "sets the target to a func_areaportal or target_speaker with the same targetname."
|
||||||
|
message(string) : "sets a string to be displayed when triggered"
|
||||||
|
team(string) : "<teamtext> sets that all doors with the same team value will open if any door of them gets activated."
|
||||||
|
health(integer) : "1 sets that the door must be shoot open instead of touching it."
|
||||||
|
angle(string) : "sets the opening direction of the door (0 default; -1 = upwards; -2 = downwards)."
|
||||||
|
speed(integer) : "sets the movement speed (100 default)."
|
||||||
|
wait(integer) : "sets the seconds before returning (3 default, -1 = never return)."
|
||||||
|
lip(integer) : "sets the lip remaining at end of move (8 default)."
|
||||||
|
dmg(integer) : "sets a damage to inflict when blocked (2 default)."
|
||||||
|
_minlight(float) : "sets that the door glows - # options can be 0.0 to 1.0."
|
||||||
|
sounds(choices) : "sound type" =
|
||||||
|
[
|
||||||
|
1 : "for a silent sound"
|
||||||
|
2 : "for a light sound"
|
||||||
|
3 : "for a medium sound"
|
||||||
|
4 : "for a heavy sound"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
@SolidClass base(AppearFlags, Door) = func_door : "Used for a simple door."
|
||||||
|
[
|
||||||
|
]
|
||||||
|
|
||||||
|
@SolidClass base(AppearFlags, Door) = func_door_rotating : "Used for a simple door."
|
||||||
|
[
|
||||||
|
spawnflags(Flags) =
|
||||||
|
[
|
||||||
|
2 : "reverse" : 0 : "will cause the door to rotate in the opposite direction."
|
||||||
|
64 : "x_axis" : 0 : "rotate on the x axis."
|
||||||
|
128 : "y_axis" : 0 : "rotate on the y axis."
|
||||||
|
]
|
||||||
|
distance(integer) : "sets the degrees the door will be rotated."
|
||||||
|
]
|
||||||
|
|
||||||
|
@SolidClass base(AppearFlags) = func_plat : "Plats are always drawn in the extended position, so they will light correctly.If the plat is the target of another trigger or button, it will start out disabled inthe extended position until it is trigger, when it will lower and become a normal plat."
|
||||||
|
[
|
||||||
|
spawnflags(Flags) =
|
||||||
|
[
|
||||||
|
1 : "plat_low_trigger" : 0 : ""
|
||||||
|
]
|
||||||
|
height(integer) : "sets the height the platform will move up (positive value) or moves down (negative value)."
|
||||||
|
speed(integer) : "sets movement speed (150 default)."
|
||||||
|
accel(integer) : "sets the acceleration when the plat starts to move."
|
||||||
|
decel(integer) : "sets the deceleration when the plat ends to move."
|
||||||
|
dmg(integer) : "sets a damage to inflict when blocked (2 default)."
|
||||||
|
_minlight(float) : "sets that the plat glows - # options can be 0.0 to 1.0."
|
||||||
|
sounds(choices) : "sound type" =
|
||||||
|
[
|
||||||
|
1 : "for a base fast sound"
|
||||||
|
2 : "for a chain slow sound"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
@SolidClass base(AppearFlags) = func_rotating : "You need to have an origin brush as part of this entity. The center of that brush will be the point around which it is rotated. It will rotate around the Z axis by default."
|
||||||
|
[
|
||||||
|
spawnflags(Flags) =
|
||||||
|
[
|
||||||
|
1 : "start_on" : 0 : "will activate the rotation by the world."
|
||||||
|
2 : "reverse" : 0 : "will cause the entity to rotate in the opposite direction."
|
||||||
|
4 : "x_axis" : 0 : "rotate on the x axis."
|
||||||
|
8 : "y_axis" : 0 : "rotate on the y axis."
|
||||||
|
16 : "touch_pain" : 0 : ""
|
||||||
|
32 : "stop" : 0 : "stop moving instead of pushing entities."
|
||||||
|
64 : "animated" : 0 : ""
|
||||||
|
128 : "animated_fast" : 0 : ""
|
||||||
|
]
|
||||||
|
speed(integer) : "sets movement speed (100 default)."
|
||||||
|
dmg(integer) : "sets a damage to inflict when blocked (2 default)."
|
||||||
|
_minlight(float) : "sets that the rotating brush glows - # options can be 0.0 to 1.0."
|
||||||
|
]
|
||||||
|
|
||||||
|
@SolidClass base(AppearFlags) = func_water : "Func_water is a moveable water brush. It must be targeted to operate. Use a non-water texture at your own risk."
|
||||||
|
[
|
||||||
|
spawnflags(Flags) =
|
||||||
|
[
|
||||||
|
1 : "start_open" : 0 : "causes the water to move to its destination when spawned and operate in reverse."
|
||||||
|
]
|
||||||
|
speed(integer) : "sets the movement speed (25 default)."
|
||||||
|
wait(integer) : "sets the seconds before returning (-1 default, -1 = TOGGLE)."
|
||||||
|
lip(integer) : "sets the lip remaining at end of move (0 default)."
|
||||||
|
angle(string) : "sets the opening direction of the water (0 default; -1 = upwards; -2 = downwards)."
|
||||||
|
sounds(choices) : "sound type" =
|
||||||
|
[
|
||||||
|
0 : "no sound"
|
||||||
|
1 : "for a water sound"
|
||||||
|
2 : "for a lava sound"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
@SolidClass base(AppearFlags) = func_train : "Trains are moving platforms that players can ride (if toggle is set).The targets origin specifies the min point of the train at each corner (path_corner).The train spawns at the first target it is pointing at.If the train is the target of a button or trigger, it will not begin moving until activated."
|
||||||
|
[
|
||||||
|
spawnflags(Flags) =
|
||||||
|
[
|
||||||
|
1 : "start_on" : 0 : "will activate the rotation by the world."
|
||||||
|
2 : "toggle" : 0 : "will move the standing people with the train."
|
||||||
|
4 : "block_stops" : 0 : "will stop the train while blocking (only if no dmg is set)."
|
||||||
|
]
|
||||||
|
target(string) : "sets the target to a path corner with the same targetname."
|
||||||
|
targetname(string) : "sets the target from a func_button, func_timer, etc. with the same target."
|
||||||
|
speed(integer) : "sets movement speed (100 default)."
|
||||||
|
dmg(integer) : "sets a damage to inflict when blocked (2 default)."
|
||||||
|
_minlight(float) : "sets that the platform glows - # options can be 0.0 to 1.0."
|
||||||
|
]
|
||||||
|
|
||||||
|
@PointClass base(AppearFlags) color(80 25 160) size(-8 -8 -8, 8 8 8) = trigger_elevator : "Entity to make a func_train behave like an elevator. Place path_corner's at each floor and set the func_button at that floor to target the trigger_elevator and pathtarget the path_corner."
|
||||||
|
[
|
||||||
|
target(string) : "sets the target to the func_train elevator with the same targetname."
|
||||||
|
targetname(string) : "sets the target from a func_button, func_timer, etc. with the same target."
|
||||||
|
]
|
||||||
|
|
||||||
|
@PointClass base(AppearFlags) color(80 25 160) size(-8 -8 -8, 8 8 8) = func_timer : "Timer for trigger lots of stuff. Target it with any entity."
|
||||||
|
[
|
||||||
|
spawnflags(Flags) =
|
||||||
|
[
|
||||||
|
1 : "start_on" : 0 : "will activate the timer by the world."
|
||||||
|
]
|
||||||
|
target(string) : "sets the target to any other entities with the same targetname."
|
||||||
|
wait(integer) : "sets the base time between triggering all targets (1 default)."
|
||||||
|
random(integer) : "sets the wait variance, so the basic time between firing is a random time (0 default)."
|
||||||
|
delay(integer) : "sets a delay before first firing when turned on (0 default)."
|
||||||
|
pausetime(integer) : "sets an additional delay used only the very first time and only if spawned with START_ON."
|
||||||
|
]
|
||||||
|
|
||||||
|
@SolidClass base(AppearFlags) = func_conveyor : "Conveyors are stationary brushes that move what's on them.The brush should be have a surface with at least one current content enabled."
|
||||||
|
[
|
||||||
|
spawnflags(Flags) =
|
||||||
|
[
|
||||||
|
1 : "start_on" : 0 : ""
|
||||||
|
2 : "toggle" : 0 : ""
|
||||||
|
]
|
||||||
|
speed(integer) : "sets the movement speed (100 default)."
|
||||||
|
]
|
||||||
|
|
||||||
|
// TODO - should this have sounds/lip/etc from base(Door)?
|
||||||
|
@SolidClass base(AppearFlags) = func_door_secret : "A secret door. Slide back and then to the side."
|
||||||
|
[
|
||||||
|
spawnflags(Flags) =
|
||||||
|
[
|
||||||
|
1 : "always_shoot" : 0 : "the door is shootable even if targeted."
|
||||||
|
2 : "1st_left" : 0 : "the 1st move is left of arrow."
|
||||||
|
4 : "1st_down" : 0 : "the 1st move is down from arrow."
|
||||||
|
]
|
||||||
|
targetname(string) : "sets the target from a func_button, func_timer, etc. with the same target."
|
||||||
|
target(string) : "sets the target to a func_areaportal or target_speaker with the same targetname."
|
||||||
|
message(string) : "sets a string to be displayed when triggered - <messagetext> can be your own value."
|
||||||
|
health(integer) : "1 sets that the door must be shoot open instead of touching it."
|
||||||
|
angle(string) : "sets the opening direction of the door (0 default; -1 = upwards; -2 = downwards)."
|
||||||
|
speed(integer) : "sets the movement speed (100 default)."
|
||||||
|
wait(integer) : "sets the seconds before returning (5 default, -1 = never return)."
|
||||||
|
dmg(integer) : "sets a damage to inflict when blocked (2 default)."
|
||||||
|
_minlight(float) : "sets that the door glows - # options can be 0.0 to 1.0."
|
||||||
|
]
|
||||||
|
|
||||||
|
@SolidClass base(AppearFlags) = func_button : "When a button is touched, it moves some distance in the direction of it's angle, triggers all of it's targets, waits some time, then returns to it's original position where it can be triggered again."
|
||||||
|
[
|
||||||
|
target(string) : "sets the target to any other entities with the same targetname."
|
||||||
|
health(integer) : "sets that the button must be killed instead of touched."
|
||||||
|
angle(string) : "sets the moving direction."
|
||||||
|
speed(integer) : "sets the movement speed (40 default)."
|
||||||
|
wait(integer) : "sets the seconds before returning (1 default, -1 = never return)."
|
||||||
|
lip(integer) : "sets the lip remaining at end of move (4 default)."
|
||||||
|
delay(integer) : "sets a delay before first firing when turned on (0 default)."
|
||||||
|
_minlight(float) : "sets that the door glows - # options can be 0.0 to 1.0."
|
||||||
|
sounds(choices) : "sound type" =
|
||||||
|
[
|
||||||
|
1 : "for a silent sound"
|
||||||
|
2 : "for a steam metal sound"
|
||||||
|
3 : "for a wooden clunk sound"
|
||||||
|
4 : "for a metallic click sound"
|
||||||
|
5 : "for an in-out sound"
|
||||||
|
]
|
||||||
|
]
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,153 +0,0 @@
|
|||||||
// Copyright 2007, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
// Google Mock - a framework for writing C++ mock classes.
|
|
||||||
//
|
|
||||||
// This file implements some commonly used cardinalities. More
|
|
||||||
// cardinalities can be defined by the user implementing the
|
|
||||||
// CardinalityInterface interface if necessary.
|
|
||||||
|
|
||||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
|
||||||
|
|
||||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
|
|
||||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
|
|
||||||
|
|
||||||
#include <limits.h>
|
|
||||||
#include <ostream> // NOLINT
|
|
||||||
#include "gmock/internal/gmock-port.h"
|
|
||||||
#include "gtest/gtest.h"
|
|
||||||
|
|
||||||
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
|
|
||||||
/* class A needs to have dll-interface to be used by clients of class B */)
|
|
||||||
|
|
||||||
namespace testing {
|
|
||||||
|
|
||||||
// To implement a cardinality Foo, define:
|
|
||||||
// 1. a class FooCardinality that implements the
|
|
||||||
// CardinalityInterface interface, and
|
|
||||||
// 2. a factory function that creates a Cardinality object from a
|
|
||||||
// const FooCardinality*.
|
|
||||||
//
|
|
||||||
// The two-level delegation design follows that of Matcher, providing
|
|
||||||
// consistency for extension developers. It also eases ownership
|
|
||||||
// management as Cardinality objects can now be copied like plain values.
|
|
||||||
|
|
||||||
// The implementation of a cardinality.
|
|
||||||
class CardinalityInterface {
|
|
||||||
public:
|
|
||||||
virtual ~CardinalityInterface() {}
|
|
||||||
|
|
||||||
// Conservative estimate on the lower/upper bound of the number of
|
|
||||||
// calls allowed.
|
|
||||||
virtual int ConservativeLowerBound() const { return 0; }
|
|
||||||
virtual int ConservativeUpperBound() const { return INT_MAX; }
|
|
||||||
|
|
||||||
// Returns true iff call_count calls will satisfy this cardinality.
|
|
||||||
virtual bool IsSatisfiedByCallCount(int call_count) const = 0;
|
|
||||||
|
|
||||||
// Returns true iff call_count calls will saturate this cardinality.
|
|
||||||
virtual bool IsSaturatedByCallCount(int call_count) const = 0;
|
|
||||||
|
|
||||||
// Describes self to an ostream.
|
|
||||||
virtual void DescribeTo(::std::ostream* os) const = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
// A Cardinality is a copyable and IMMUTABLE (except by assignment)
|
|
||||||
// object that specifies how many times a mock function is expected to
|
|
||||||
// be called. The implementation of Cardinality is just a linked_ptr
|
|
||||||
// to const CardinalityInterface, so copying is fairly cheap.
|
|
||||||
// Don't inherit from Cardinality!
|
|
||||||
class GTEST_API_ Cardinality {
|
|
||||||
public:
|
|
||||||
// Constructs a null cardinality. Needed for storing Cardinality
|
|
||||||
// objects in STL containers.
|
|
||||||
Cardinality() {}
|
|
||||||
|
|
||||||
// Constructs a Cardinality from its implementation.
|
|
||||||
explicit Cardinality(const CardinalityInterface* impl) : impl_(impl) {}
|
|
||||||
|
|
||||||
// Conservative estimate on the lower/upper bound of the number of
|
|
||||||
// calls allowed.
|
|
||||||
int ConservativeLowerBound() const { return impl_->ConservativeLowerBound(); }
|
|
||||||
int ConservativeUpperBound() const { return impl_->ConservativeUpperBound(); }
|
|
||||||
|
|
||||||
// Returns true iff call_count calls will satisfy this cardinality.
|
|
||||||
bool IsSatisfiedByCallCount(int call_count) const {
|
|
||||||
return impl_->IsSatisfiedByCallCount(call_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true iff call_count calls will saturate this cardinality.
|
|
||||||
bool IsSaturatedByCallCount(int call_count) const {
|
|
||||||
return impl_->IsSaturatedByCallCount(call_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true iff call_count calls will over-saturate this
|
|
||||||
// cardinality, i.e. exceed the maximum number of allowed calls.
|
|
||||||
bool IsOverSaturatedByCallCount(int call_count) const {
|
|
||||||
return impl_->IsSaturatedByCallCount(call_count) &&
|
|
||||||
!impl_->IsSatisfiedByCallCount(call_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Describes self to an ostream
|
|
||||||
void DescribeTo(::std::ostream* os) const { impl_->DescribeTo(os); }
|
|
||||||
|
|
||||||
// Describes the given actual call count to an ostream.
|
|
||||||
static void DescribeActualCallCountTo(int actual_call_count,
|
|
||||||
::std::ostream* os);
|
|
||||||
|
|
||||||
private:
|
|
||||||
internal::linked_ptr<const CardinalityInterface> impl_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Creates a cardinality that allows at least n calls.
|
|
||||||
GTEST_API_ Cardinality AtLeast(int n);
|
|
||||||
|
|
||||||
// Creates a cardinality that allows at most n calls.
|
|
||||||
GTEST_API_ Cardinality AtMost(int n);
|
|
||||||
|
|
||||||
// Creates a cardinality that allows any number of calls.
|
|
||||||
GTEST_API_ Cardinality AnyNumber();
|
|
||||||
|
|
||||||
// Creates a cardinality that allows between min and max calls.
|
|
||||||
GTEST_API_ Cardinality Between(int min, int max);
|
|
||||||
|
|
||||||
// Creates a cardinality that allows exactly n calls.
|
|
||||||
GTEST_API_ Cardinality Exactly(int n);
|
|
||||||
|
|
||||||
// Creates a cardinality from its implementation.
|
|
||||||
inline Cardinality MakeCardinality(const CardinalityInterface* c) {
|
|
||||||
return Cardinality(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace testing
|
|
||||||
|
|
||||||
GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
|
|
||||||
|
|
||||||
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,833 +0,0 @@
|
|||||||
$$ -*- mode: c++; -*-
|
|
||||||
$$ This is a Pump source file. Please use Pump to convert it to
|
|
||||||
$$ gmock-generated-actions.h.
|
|
||||||
$$
|
|
||||||
$var n = 10 $$ The maximum arity we support.
|
|
||||||
$$}} This meta comment fixes auto-indentation in editors.
|
|
||||||
// Copyright 2007, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
// Google Mock - a framework for writing C++ mock classes.
|
|
||||||
//
|
|
||||||
// This file implements some commonly used variadic actions.
|
|
||||||
|
|
||||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
|
||||||
|
|
||||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
|
|
||||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
|
|
||||||
|
|
||||||
#include "gmock/gmock-actions.h"
|
|
||||||
#include "gmock/internal/gmock-port.h"
|
|
||||||
|
|
||||||
namespace testing {
|
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
// InvokeHelper<F> knows how to unpack an N-tuple and invoke an N-ary
|
|
||||||
// function, method, or callback with the unpacked values, where F is
|
|
||||||
// a function type that takes N arguments.
|
|
||||||
template <typename Result, typename ArgumentTuple>
|
|
||||||
class InvokeHelper;
|
|
||||||
|
|
||||||
|
|
||||||
$var max_callback_arity = 5
|
|
||||||
$range i 0..n
|
|
||||||
$for i [[
|
|
||||||
$range j 1..i
|
|
||||||
$var types = [[$for j [[, typename A$j]]]]
|
|
||||||
$var as = [[$for j, [[A$j]]]]
|
|
||||||
$var args = [[$if i==0 [[]] $else [[ args]]]]
|
|
||||||
$var gets = [[$for j, [[get<$(j - 1)>(args)]]]]
|
|
||||||
template <typename R$types>
|
|
||||||
class InvokeHelper<R, ::testing::tuple<$as> > {
|
|
||||||
public:
|
|
||||||
template <typename Function>
|
|
||||||
static R Invoke(Function function, const ::testing::tuple<$as>&$args) {
|
|
||||||
return function($gets);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Class, typename MethodPtr>
|
|
||||||
static R InvokeMethod(Class* obj_ptr,
|
|
||||||
MethodPtr method_ptr,
|
|
||||||
const ::testing::tuple<$as>&$args) {
|
|
||||||
return (obj_ptr->*method_ptr)($gets);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$if i <= max_callback_arity [[
|
|
||||||
template <typename CallbackType>
|
|
||||||
static R InvokeCallback(CallbackType* callback,
|
|
||||||
const ::testing::tuple<$as>&$args) {
|
|
||||||
return callback->Run($gets);
|
|
||||||
}
|
|
||||||
]] $else [[
|
|
||||||
// There is no InvokeCallback() for $i-tuples
|
|
||||||
]]
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
]]
|
|
||||||
// Implements the Invoke(callback) action.
|
|
||||||
template <typename CallbackType>
|
|
||||||
class InvokeCallbackAction {
|
|
||||||
public:
|
|
||||||
// The c'tor takes ownership of the callback.
|
|
||||||
explicit InvokeCallbackAction(CallbackType* callback)
|
|
||||||
: callback_(callback) {
|
|
||||||
callback->CheckIsRepeatable(); // Makes sure the callback is permanent.
|
|
||||||
}
|
|
||||||
|
|
||||||
// This type conversion operator template allows Invoke(callback) to
|
|
||||||
// be used wherever the callback's type is compatible with that of
|
|
||||||
// the mock function, i.e. if the mock function's arguments can be
|
|
||||||
// implicitly converted to the callback's arguments and the
|
|
||||||
// callback's result can be implicitly converted to the mock
|
|
||||||
// function's result.
|
|
||||||
template <typename Result, typename ArgumentTuple>
|
|
||||||
Result Perform(const ArgumentTuple& args) const {
|
|
||||||
return InvokeHelper<Result, ArgumentTuple>::InvokeCallback(
|
|
||||||
callback_.get(), args);
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
const linked_ptr<CallbackType> callback_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// An INTERNAL macro for extracting the type of a tuple field. It's
|
|
||||||
// subject to change without notice - DO NOT USE IN USER CODE!
|
|
||||||
#define GMOCK_FIELD_(Tuple, N) \
|
|
||||||
typename ::testing::tuple_element<N, Tuple>::type
|
|
||||||
|
|
||||||
$range i 1..n
|
|
||||||
|
|
||||||
// SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::type is the
|
|
||||||
// type of an n-ary function whose i-th (1-based) argument type is the
|
|
||||||
// k{i}-th (0-based) field of ArgumentTuple, which must be a tuple
|
|
||||||
// type, and whose return type is Result. For example,
|
|
||||||
// SelectArgs<int, ::testing::tuple<bool, char, double, long>, 0, 3>::type
|
|
||||||
// is int(bool, long).
|
|
||||||
//
|
|
||||||
// SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::Select(args)
|
|
||||||
// returns the selected fields (k1, k2, ..., k_n) of args as a tuple.
|
|
||||||
// For example,
|
|
||||||
// SelectArgs<int, tuple<bool, char, double>, 2, 0>::Select(
|
|
||||||
// ::testing::make_tuple(true, 'a', 2.5))
|
|
||||||
// returns tuple (2.5, true).
|
|
||||||
//
|
|
||||||
// The numbers in list k1, k2, ..., k_n must be >= 0, where n can be
|
|
||||||
// in the range [0, $n]. Duplicates are allowed and they don't have
|
|
||||||
// to be in an ascending or descending order.
|
|
||||||
|
|
||||||
template <typename Result, typename ArgumentTuple, $for i, [[int k$i]]>
|
|
||||||
class SelectArgs {
|
|
||||||
public:
|
|
||||||
typedef Result type($for i, [[GMOCK_FIELD_(ArgumentTuple, k$i)]]);
|
|
||||||
typedef typename Function<type>::ArgumentTuple SelectedArgs;
|
|
||||||
static SelectedArgs Select(const ArgumentTuple& args) {
|
|
||||||
return SelectedArgs($for i, [[get<k$i>(args)]]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
$for i [[
|
|
||||||
$range j 1..n
|
|
||||||
$range j1 1..i-1
|
|
||||||
template <typename Result, typename ArgumentTuple$for j1[[, int k$j1]]>
|
|
||||||
class SelectArgs<Result, ArgumentTuple,
|
|
||||||
$for j, [[$if j <= i-1 [[k$j]] $else [[-1]]]]> {
|
|
||||||
public:
|
|
||||||
typedef Result type($for j1, [[GMOCK_FIELD_(ArgumentTuple, k$j1)]]);
|
|
||||||
typedef typename Function<type>::ArgumentTuple SelectedArgs;
|
|
||||||
static SelectedArgs Select(const ArgumentTuple& [[]]
|
|
||||||
$if i == 1 [[/* args */]] $else [[args]]) {
|
|
||||||
return SelectedArgs($for j1, [[get<k$j1>(args)]]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
]]
|
|
||||||
#undef GMOCK_FIELD_
|
|
||||||
|
|
||||||
$var ks = [[$for i, [[k$i]]]]
|
|
||||||
|
|
||||||
// Implements the WithArgs action.
|
|
||||||
template <typename InnerAction, $for i, [[int k$i = -1]]>
|
|
||||||
class WithArgsAction {
|
|
||||||
public:
|
|
||||||
explicit WithArgsAction(const InnerAction& action) : action_(action) {}
|
|
||||||
|
|
||||||
template <typename F>
|
|
||||||
operator Action<F>() const { return MakeAction(new Impl<F>(action_)); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
template <typename F>
|
|
||||||
class Impl : public ActionInterface<F> {
|
|
||||||
public:
|
|
||||||
typedef typename Function<F>::Result Result;
|
|
||||||
typedef typename Function<F>::ArgumentTuple ArgumentTuple;
|
|
||||||
|
|
||||||
explicit Impl(const InnerAction& action) : action_(action) {}
|
|
||||||
|
|
||||||
virtual Result Perform(const ArgumentTuple& args) {
|
|
||||||
return action_.Perform(SelectArgs<Result, ArgumentTuple, $ks>::Select(args));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
typedef typename SelectArgs<Result, ArgumentTuple,
|
|
||||||
$ks>::type InnerFunctionType;
|
|
||||||
|
|
||||||
Action<InnerFunctionType> action_;
|
|
||||||
};
|
|
||||||
|
|
||||||
const InnerAction action_;
|
|
||||||
|
|
||||||
GTEST_DISALLOW_ASSIGN_(WithArgsAction);
|
|
||||||
};
|
|
||||||
|
|
||||||
// A macro from the ACTION* family (defined later in this file)
|
|
||||||
// defines an action that can be used in a mock function. Typically,
|
|
||||||
// these actions only care about a subset of the arguments of the mock
|
|
||||||
// function. For example, if such an action only uses the second
|
|
||||||
// argument, it can be used in any mock function that takes >= 2
|
|
||||||
// arguments where the type of the second argument is compatible.
|
|
||||||
//
|
|
||||||
// Therefore, the action implementation must be prepared to take more
|
|
||||||
// arguments than it needs. The ExcessiveArg type is used to
|
|
||||||
// represent those excessive arguments. In order to keep the compiler
|
|
||||||
// error messages tractable, we define it in the testing namespace
|
|
||||||
// instead of testing::internal. However, this is an INTERNAL TYPE
|
|
||||||
// and subject to change without notice, so a user MUST NOT USE THIS
|
|
||||||
// TYPE DIRECTLY.
|
|
||||||
struct ExcessiveArg {};
|
|
||||||
|
|
||||||
// A helper class needed for implementing the ACTION* macros.
|
|
||||||
template <typename Result, class Impl>
|
|
||||||
class ActionHelper {
|
|
||||||
public:
|
|
||||||
$range i 0..n
|
|
||||||
$for i
|
|
||||||
|
|
||||||
[[
|
|
||||||
$var template = [[$if i==0 [[]] $else [[
|
|
||||||
$range j 0..i-1
|
|
||||||
template <$for j, [[typename A$j]]>
|
|
||||||
]]]]
|
|
||||||
$range j 0..i-1
|
|
||||||
$var As = [[$for j, [[A$j]]]]
|
|
||||||
$var as = [[$for j, [[get<$j>(args)]]]]
|
|
||||||
$range k 1..n-i
|
|
||||||
$var eas = [[$for k, [[ExcessiveArg()]]]]
|
|
||||||
$var arg_list = [[$if (i==0) | (i==n) [[$as$eas]] $else [[$as, $eas]]]]
|
|
||||||
$template
|
|
||||||
static Result Perform(Impl* impl, const ::testing::tuple<$As>& args) {
|
|
||||||
return impl->template gmock_PerformImpl<$As>(args, $arg_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
]]
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
|
|
||||||
// Various overloads for Invoke().
|
|
||||||
|
|
||||||
// WithArgs<N1, N2, ..., Nk>(an_action) creates an action that passes
|
|
||||||
// the selected arguments of the mock function to an_action and
|
|
||||||
// performs it. It serves as an adaptor between actions with
|
|
||||||
// different argument lists. C++ doesn't support default arguments for
|
|
||||||
// function templates, so we have to overload it.
|
|
||||||
|
|
||||||
$range i 1..n
|
|
||||||
$for i [[
|
|
||||||
$range j 1..i
|
|
||||||
template <$for j [[int k$j, ]]typename InnerAction>
|
|
||||||
inline internal::WithArgsAction<InnerAction$for j [[, k$j]]>
|
|
||||||
WithArgs(const InnerAction& action) {
|
|
||||||
return internal::WithArgsAction<InnerAction$for j [[, k$j]]>(action);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
]]
|
|
||||||
// Creates an action that does actions a1, a2, ..., sequentially in
|
|
||||||
// each invocation.
|
|
||||||
$range i 2..n
|
|
||||||
$for i [[
|
|
||||||
$range j 2..i
|
|
||||||
$var types = [[$for j, [[typename Action$j]]]]
|
|
||||||
$var Aas = [[$for j [[, Action$j a$j]]]]
|
|
||||||
|
|
||||||
template <typename Action1, $types>
|
|
||||||
$range k 1..i-1
|
|
||||||
|
|
||||||
inline $for k [[internal::DoBothAction<Action$k, ]]Action$i$for k [[>]]
|
|
||||||
|
|
||||||
DoAll(Action1 a1$Aas) {
|
|
||||||
$if i==2 [[
|
|
||||||
|
|
||||||
return internal::DoBothAction<Action1, Action2>(a1, a2);
|
|
||||||
]] $else [[
|
|
||||||
$range j2 2..i
|
|
||||||
|
|
||||||
return DoAll(a1, DoAll($for j2, [[a$j2]]));
|
|
||||||
]]
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
} // namespace testing
|
|
||||||
|
|
||||||
// The ACTION* family of macros can be used in a namespace scope to
|
|
||||||
// define custom actions easily. The syntax:
|
|
||||||
//
|
|
||||||
// ACTION(name) { statements; }
|
|
||||||
//
|
|
||||||
// will define an action with the given name that executes the
|
|
||||||
// statements. The value returned by the statements will be used as
|
|
||||||
// the return value of the action. Inside the statements, you can
|
|
||||||
// refer to the K-th (0-based) argument of the mock function by
|
|
||||||
// 'argK', and refer to its type by 'argK_type'. For example:
|
|
||||||
//
|
|
||||||
// ACTION(IncrementArg1) {
|
|
||||||
// arg1_type temp = arg1;
|
|
||||||
// return ++(*temp);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// allows you to write
|
|
||||||
//
|
|
||||||
// ...WillOnce(IncrementArg1());
|
|
||||||
//
|
|
||||||
// You can also refer to the entire argument tuple and its type by
|
|
||||||
// 'args' and 'args_type', and refer to the mock function type and its
|
|
||||||
// return type by 'function_type' and 'return_type'.
|
|
||||||
//
|
|
||||||
// Note that you don't need to specify the types of the mock function
|
|
||||||
// arguments. However rest assured that your code is still type-safe:
|
|
||||||
// you'll get a compiler error if *arg1 doesn't support the ++
|
|
||||||
// operator, or if the type of ++(*arg1) isn't compatible with the
|
|
||||||
// mock function's return type, for example.
|
|
||||||
//
|
|
||||||
// Sometimes you'll want to parameterize the action. For that you can use
|
|
||||||
// another macro:
|
|
||||||
//
|
|
||||||
// ACTION_P(name, param_name) { statements; }
|
|
||||||
//
|
|
||||||
// For example:
|
|
||||||
//
|
|
||||||
// ACTION_P(Add, n) { return arg0 + n; }
|
|
||||||
//
|
|
||||||
// will allow you to write:
|
|
||||||
//
|
|
||||||
// ...WillOnce(Add(5));
|
|
||||||
//
|
|
||||||
// Note that you don't need to provide the type of the parameter
|
|
||||||
// either. If you need to reference the type of a parameter named
|
|
||||||
// 'foo', you can write 'foo_type'. For example, in the body of
|
|
||||||
// ACTION_P(Add, n) above, you can write 'n_type' to refer to the type
|
|
||||||
// of 'n'.
|
|
||||||
//
|
|
||||||
// We also provide ACTION_P2, ACTION_P3, ..., up to ACTION_P$n to support
|
|
||||||
// multi-parameter actions.
|
|
||||||
//
|
|
||||||
// For the purpose of typing, you can view
|
|
||||||
//
|
|
||||||
// ACTION_Pk(Foo, p1, ..., pk) { ... }
|
|
||||||
//
|
|
||||||
// as shorthand for
|
|
||||||
//
|
|
||||||
// template <typename p1_type, ..., typename pk_type>
|
|
||||||
// FooActionPk<p1_type, ..., pk_type> Foo(p1_type p1, ..., pk_type pk) { ... }
|
|
||||||
//
|
|
||||||
// In particular, you can provide the template type arguments
|
|
||||||
// explicitly when invoking Foo(), as in Foo<long, bool>(5, false);
|
|
||||||
// although usually you can rely on the compiler to infer the types
|
|
||||||
// for you automatically. You can assign the result of expression
|
|
||||||
// Foo(p1, ..., pk) to a variable of type FooActionPk<p1_type, ...,
|
|
||||||
// pk_type>. This can be useful when composing actions.
|
|
||||||
//
|
|
||||||
// You can also overload actions with different numbers of parameters:
|
|
||||||
//
|
|
||||||
// ACTION_P(Plus, a) { ... }
|
|
||||||
// ACTION_P2(Plus, a, b) { ... }
|
|
||||||
//
|
|
||||||
// While it's tempting to always use the ACTION* macros when defining
|
|
||||||
// a new action, you should also consider implementing ActionInterface
|
|
||||||
// or using MakePolymorphicAction() instead, especially if you need to
|
|
||||||
// use the action a lot. While these approaches require more work,
|
|
||||||
// they give you more control on the types of the mock function
|
|
||||||
// arguments and the action parameters, which in general leads to
|
|
||||||
// better compiler error messages that pay off in the long run. They
|
|
||||||
// also allow overloading actions based on parameter types (as opposed
|
|
||||||
// to just based on the number of parameters).
|
|
||||||
//
|
|
||||||
// CAVEAT:
|
|
||||||
//
|
|
||||||
// ACTION*() can only be used in a namespace scope. The reason is
|
|
||||||
// that C++ doesn't yet allow function-local types to be used to
|
|
||||||
// instantiate templates. The up-coming C++0x standard will fix this.
|
|
||||||
// Once that's done, we'll consider supporting using ACTION*() inside
|
|
||||||
// a function.
|
|
||||||
//
|
|
||||||
// MORE INFORMATION:
|
|
||||||
//
|
|
||||||
// To learn more about using these macros, please search for 'ACTION'
|
|
||||||
// on https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md
|
|
||||||
|
|
||||||
$range i 0..n
|
|
||||||
$range k 0..n-1
|
|
||||||
|
|
||||||
// An internal macro needed for implementing ACTION*().
|
|
||||||
#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_\
|
|
||||||
const args_type& args GTEST_ATTRIBUTE_UNUSED_
|
|
||||||
$for k [[, \
|
|
||||||
arg$k[[]]_type arg$k GTEST_ATTRIBUTE_UNUSED_]]
|
|
||||||
|
|
||||||
|
|
||||||
// Sometimes you want to give an action explicit template parameters
|
|
||||||
// that cannot be inferred from its value parameters. ACTION() and
|
|
||||||
// ACTION_P*() don't support that. ACTION_TEMPLATE() remedies that
|
|
||||||
// and can be viewed as an extension to ACTION() and ACTION_P*().
|
|
||||||
//
|
|
||||||
// The syntax:
|
|
||||||
//
|
|
||||||
// ACTION_TEMPLATE(ActionName,
|
|
||||||
// HAS_m_TEMPLATE_PARAMS(kind1, name1, ..., kind_m, name_m),
|
|
||||||
// AND_n_VALUE_PARAMS(p1, ..., p_n)) { statements; }
|
|
||||||
//
|
|
||||||
// defines an action template that takes m explicit template
|
|
||||||
// parameters and n value parameters. name_i is the name of the i-th
|
|
||||||
// template parameter, and kind_i specifies whether it's a typename,
|
|
||||||
// an integral constant, or a template. p_i is the name of the i-th
|
|
||||||
// value parameter.
|
|
||||||
//
|
|
||||||
// Example:
|
|
||||||
//
|
|
||||||
// // DuplicateArg<k, T>(output) converts the k-th argument of the mock
|
|
||||||
// // function to type T and copies it to *output.
|
|
||||||
// ACTION_TEMPLATE(DuplicateArg,
|
|
||||||
// HAS_2_TEMPLATE_PARAMS(int, k, typename, T),
|
|
||||||
// AND_1_VALUE_PARAMS(output)) {
|
|
||||||
// *output = T(::testing::get<k>(args));
|
|
||||||
// }
|
|
||||||
// ...
|
|
||||||
// int n;
|
|
||||||
// EXPECT_CALL(mock, Foo(_, _))
|
|
||||||
// .WillOnce(DuplicateArg<1, unsigned char>(&n));
|
|
||||||
//
|
|
||||||
// To create an instance of an action template, write:
|
|
||||||
//
|
|
||||||
// ActionName<t1, ..., t_m>(v1, ..., v_n)
|
|
||||||
//
|
|
||||||
// where the ts are the template arguments and the vs are the value
|
|
||||||
// arguments. The value argument types are inferred by the compiler.
|
|
||||||
// If you want to explicitly specify the value argument types, you can
|
|
||||||
// provide additional template arguments:
|
|
||||||
//
|
|
||||||
// ActionName<t1, ..., t_m, u1, ..., u_k>(v1, ..., v_n)
|
|
||||||
//
|
|
||||||
// where u_i is the desired type of v_i.
|
|
||||||
//
|
|
||||||
// ACTION_TEMPLATE and ACTION/ACTION_P* can be overloaded on the
|
|
||||||
// number of value parameters, but not on the number of template
|
|
||||||
// parameters. Without the restriction, the meaning of the following
|
|
||||||
// is unclear:
|
|
||||||
//
|
|
||||||
// OverloadedAction<int, bool>(x);
|
|
||||||
//
|
|
||||||
// Are we using a single-template-parameter action where 'bool' refers
|
|
||||||
// to the type of x, or are we using a two-template-parameter action
|
|
||||||
// where the compiler is asked to infer the type of x?
|
|
||||||
//
|
|
||||||
// Implementation notes:
|
|
||||||
//
|
|
||||||
// GMOCK_INTERNAL_*_HAS_m_TEMPLATE_PARAMS and
|
|
||||||
// GMOCK_INTERNAL_*_AND_n_VALUE_PARAMS are internal macros for
|
|
||||||
// implementing ACTION_TEMPLATE. The main trick we use is to create
|
|
||||||
// new macro invocations when expanding a macro. For example, we have
|
|
||||||
//
|
|
||||||
// #define ACTION_TEMPLATE(name, template_params, value_params)
|
|
||||||
// ... GMOCK_INTERNAL_DECL_##template_params ...
|
|
||||||
//
|
|
||||||
// which causes ACTION_TEMPLATE(..., HAS_1_TEMPLATE_PARAMS(typename, T), ...)
|
|
||||||
// to expand to
|
|
||||||
//
|
|
||||||
// ... GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(typename, T) ...
|
|
||||||
//
|
|
||||||
// Since GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS is a macro, the
|
|
||||||
// preprocessor will continue to expand it to
|
|
||||||
//
|
|
||||||
// ... typename T ...
|
|
||||||
//
|
|
||||||
// This technique conforms to the C++ standard and is portable. It
|
|
||||||
// allows us to implement action templates using O(N) code, where N is
|
|
||||||
// the maximum number of template/value parameters supported. Without
|
|
||||||
// using it, we'd have to devote O(N^2) amount of code to implement all
|
|
||||||
// combinations of m and n.
|
|
||||||
|
|
||||||
// Declares the template parameters.
|
|
||||||
|
|
||||||
$range j 1..n
|
|
||||||
$for j [[
|
|
||||||
$range m 0..j-1
|
|
||||||
#define GMOCK_INTERNAL_DECL_HAS_$j[[]]
|
|
||||||
_TEMPLATE_PARAMS($for m, [[kind$m, name$m]]) $for m, [[kind$m name$m]]
|
|
||||||
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
// Lists the template parameters.
|
|
||||||
|
|
||||||
$for j [[
|
|
||||||
$range m 0..j-1
|
|
||||||
#define GMOCK_INTERNAL_LIST_HAS_$j[[]]
|
|
||||||
_TEMPLATE_PARAMS($for m, [[kind$m, name$m]]) $for m, [[name$m]]
|
|
||||||
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
// Declares the types of value parameters.
|
|
||||||
|
|
||||||
$for i [[
|
|
||||||
$range j 0..i-1
|
|
||||||
#define GMOCK_INTERNAL_DECL_TYPE_AND_$i[[]]
|
|
||||||
_VALUE_PARAMS($for j, [[p$j]]) $for j [[, typename p$j##_type]]
|
|
||||||
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
// Initializes the value parameters.
|
|
||||||
|
|
||||||
$for i [[
|
|
||||||
$range j 0..i-1
|
|
||||||
#define GMOCK_INTERNAL_INIT_AND_$i[[]]_VALUE_PARAMS($for j, [[p$j]])\
|
|
||||||
($for j, [[p$j##_type gmock_p$j]])$if i>0 [[ : ]]$for j, [[p$j(::testing::internal::move(gmock_p$j))]]
|
|
||||||
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
// Declares the fields for storing the value parameters.
|
|
||||||
|
|
||||||
$for i [[
|
|
||||||
$range j 0..i-1
|
|
||||||
#define GMOCK_INTERNAL_DEFN_AND_$i[[]]
|
|
||||||
_VALUE_PARAMS($for j, [[p$j]]) $for j [[p$j##_type p$j; ]]
|
|
||||||
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
// Lists the value parameters.
|
|
||||||
|
|
||||||
$for i [[
|
|
||||||
$range j 0..i-1
|
|
||||||
#define GMOCK_INTERNAL_LIST_AND_$i[[]]
|
|
||||||
_VALUE_PARAMS($for j, [[p$j]]) $for j, [[p$j]]
|
|
||||||
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
// Lists the value parameter types.
|
|
||||||
|
|
||||||
$for i [[
|
|
||||||
$range j 0..i-1
|
|
||||||
#define GMOCK_INTERNAL_LIST_TYPE_AND_$i[[]]
|
|
||||||
_VALUE_PARAMS($for j, [[p$j]]) $for j [[, p$j##_type]]
|
|
||||||
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
// Declares the value parameters.
|
|
||||||
|
|
||||||
$for i [[
|
|
||||||
$range j 0..i-1
|
|
||||||
#define GMOCK_INTERNAL_DECL_AND_$i[[]]_VALUE_PARAMS($for j, [[p$j]]) [[]]
|
|
||||||
$for j, [[p$j##_type p$j]]
|
|
||||||
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
// The suffix of the class template implementing the action template.
|
|
||||||
$for i [[
|
|
||||||
|
|
||||||
|
|
||||||
$range j 0..i-1
|
|
||||||
#define GMOCK_INTERNAL_COUNT_AND_$i[[]]_VALUE_PARAMS($for j, [[p$j]]) [[]]
|
|
||||||
$if i==1 [[P]] $elif i>=2 [[P$i]]
|
|
||||||
]]
|
|
||||||
|
|
||||||
|
|
||||||
// The name of the class template implementing the action template.
|
|
||||||
#define GMOCK_ACTION_CLASS_(name, value_params)\
|
|
||||||
GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params)
|
|
||||||
|
|
||||||
$range k 0..n-1
|
|
||||||
|
|
||||||
#define ACTION_TEMPLATE(name, template_params, value_params)\
|
|
||||||
template <GMOCK_INTERNAL_DECL_##template_params\
|
|
||||||
GMOCK_INTERNAL_DECL_TYPE_##value_params>\
|
|
||||||
class GMOCK_ACTION_CLASS_(name, value_params) {\
|
|
||||||
public:\
|
|
||||||
explicit GMOCK_ACTION_CLASS_(name, value_params)\
|
|
||||||
GMOCK_INTERNAL_INIT_##value_params {}\
|
|
||||||
template <typename F>\
|
|
||||||
class gmock_Impl : public ::testing::ActionInterface<F> {\
|
|
||||||
public:\
|
|
||||||
typedef F function_type;\
|
|
||||||
typedef typename ::testing::internal::Function<F>::Result return_type;\
|
|
||||||
typedef typename ::testing::internal::Function<F>::ArgumentTuple\
|
|
||||||
args_type;\
|
|
||||||
explicit gmock_Impl GMOCK_INTERNAL_INIT_##value_params {}\
|
|
||||||
virtual return_type Perform(const args_type& args) {\
|
|
||||||
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
|
|
||||||
Perform(this, args);\
|
|
||||||
}\
|
|
||||||
template <$for k, [[typename arg$k[[]]_type]]>\
|
|
||||||
return_type gmock_PerformImpl(const args_type& args[[]]
|
|
||||||
$for k [[, arg$k[[]]_type arg$k]]) const;\
|
|
||||||
GMOCK_INTERNAL_DEFN_##value_params\
|
|
||||||
private:\
|
|
||||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
|
||||||
};\
|
|
||||||
template <typename F> operator ::testing::Action<F>() const {\
|
|
||||||
return ::testing::Action<F>(\
|
|
||||||
new gmock_Impl<F>(GMOCK_INTERNAL_LIST_##value_params));\
|
|
||||||
}\
|
|
||||||
GMOCK_INTERNAL_DEFN_##value_params\
|
|
||||||
private:\
|
|
||||||
GTEST_DISALLOW_ASSIGN_(GMOCK_ACTION_CLASS_(name, value_params));\
|
|
||||||
};\
|
|
||||||
template <GMOCK_INTERNAL_DECL_##template_params\
|
|
||||||
GMOCK_INTERNAL_DECL_TYPE_##value_params>\
|
|
||||||
inline GMOCK_ACTION_CLASS_(name, value_params)<\
|
|
||||||
GMOCK_INTERNAL_LIST_##template_params\
|
|
||||||
GMOCK_INTERNAL_LIST_TYPE_##value_params> name(\
|
|
||||||
GMOCK_INTERNAL_DECL_##value_params) {\
|
|
||||||
return GMOCK_ACTION_CLASS_(name, value_params)<\
|
|
||||||
GMOCK_INTERNAL_LIST_##template_params\
|
|
||||||
GMOCK_INTERNAL_LIST_TYPE_##value_params>(\
|
|
||||||
GMOCK_INTERNAL_LIST_##value_params);\
|
|
||||||
}\
|
|
||||||
template <GMOCK_INTERNAL_DECL_##template_params\
|
|
||||||
GMOCK_INTERNAL_DECL_TYPE_##value_params>\
|
|
||||||
template <typename F>\
|
|
||||||
template <typename arg0_type, typename arg1_type, typename arg2_type, \
|
|
||||||
typename arg3_type, typename arg4_type, typename arg5_type, \
|
|
||||||
typename arg6_type, typename arg7_type, typename arg8_type, \
|
|
||||||
typename arg9_type>\
|
|
||||||
typename ::testing::internal::Function<F>::Result\
|
|
||||||
GMOCK_ACTION_CLASS_(name, value_params)<\
|
|
||||||
GMOCK_INTERNAL_LIST_##template_params\
|
|
||||||
GMOCK_INTERNAL_LIST_TYPE_##value_params>::gmock_Impl<F>::\
|
|
||||||
gmock_PerformImpl(\
|
|
||||||
GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
|
|
||||||
|
|
||||||
$for i
|
|
||||||
|
|
||||||
[[
|
|
||||||
$var template = [[$if i==0 [[]] $else [[
|
|
||||||
$range j 0..i-1
|
|
||||||
|
|
||||||
template <$for j, [[typename p$j##_type]]>\
|
|
||||||
]]]]
|
|
||||||
$var class_name = [[name##Action[[$if i==0 [[]] $elif i==1 [[P]]
|
|
||||||
$else [[P$i]]]]]]
|
|
||||||
$range j 0..i-1
|
|
||||||
$var ctor_param_list = [[$for j, [[p$j##_type gmock_p$j]]]]
|
|
||||||
$var param_types_and_names = [[$for j, [[p$j##_type p$j]]]]
|
|
||||||
$var inits = [[$if i==0 [[]] $else [[ : $for j, [[p$j(::testing::internal::forward<p$j##_type>(gmock_p$j))]]]]]]
|
|
||||||
$var param_field_decls = [[$for j
|
|
||||||
[[
|
|
||||||
|
|
||||||
p$j##_type p$j;\
|
|
||||||
]]]]
|
|
||||||
$var param_field_decls2 = [[$for j
|
|
||||||
[[
|
|
||||||
|
|
||||||
p$j##_type p$j;\
|
|
||||||
]]]]
|
|
||||||
$var params = [[$for j, [[p$j]]]]
|
|
||||||
$var param_types = [[$if i==0 [[]] $else [[<$for j, [[p$j##_type]]>]]]]
|
|
||||||
$var typename_arg_types = [[$for k, [[typename arg$k[[]]_type]]]]
|
|
||||||
$var arg_types_and_names = [[$for k, [[arg$k[[]]_type arg$k]]]]
|
|
||||||
$var macro_name = [[$if i==0 [[ACTION]] $elif i==1 [[ACTION_P]]
|
|
||||||
$else [[ACTION_P$i]]]]
|
|
||||||
|
|
||||||
#define $macro_name(name$for j [[, p$j]])\$template
|
|
||||||
class $class_name {\
|
|
||||||
public:\
|
|
||||||
[[$if i==1 [[explicit ]]]]$class_name($ctor_param_list)$inits {}\
|
|
||||||
template <typename F>\
|
|
||||||
class gmock_Impl : public ::testing::ActionInterface<F> {\
|
|
||||||
public:\
|
|
||||||
typedef F function_type;\
|
|
||||||
typedef typename ::testing::internal::Function<F>::Result return_type;\
|
|
||||||
typedef typename ::testing::internal::Function<F>::ArgumentTuple\
|
|
||||||
args_type;\
|
|
||||||
[[$if i==1 [[explicit ]]]]gmock_Impl($ctor_param_list)$inits {}\
|
|
||||||
virtual return_type Perform(const args_type& args) {\
|
|
||||||
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
|
|
||||||
Perform(this, args);\
|
|
||||||
}\
|
|
||||||
template <$typename_arg_types>\
|
|
||||||
return_type gmock_PerformImpl(const args_type& args, [[]]
|
|
||||||
$arg_types_and_names) const;\$param_field_decls
|
|
||||||
private:\
|
|
||||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
|
||||||
};\
|
|
||||||
template <typename F> operator ::testing::Action<F>() const {\
|
|
||||||
return ::testing::Action<F>(new gmock_Impl<F>($params));\
|
|
||||||
}\$param_field_decls2
|
|
||||||
private:\
|
|
||||||
GTEST_DISALLOW_ASSIGN_($class_name);\
|
|
||||||
};\$template
|
|
||||||
inline $class_name$param_types name($param_types_and_names) {\
|
|
||||||
return $class_name$param_types($params);\
|
|
||||||
}\$template
|
|
||||||
template <typename F>\
|
|
||||||
template <$typename_arg_types>\
|
|
||||||
typename ::testing::internal::Function<F>::Result\
|
|
||||||
$class_name$param_types::gmock_Impl<F>::gmock_PerformImpl(\
|
|
||||||
GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
|
|
||||||
]]
|
|
||||||
$$ } // This meta comment fixes auto-indentation in Emacs. It won't
|
|
||||||
$$ // show up in the generated code.
|
|
||||||
|
|
||||||
|
|
||||||
namespace testing {
|
|
||||||
|
|
||||||
|
|
||||||
// The ACTION*() macros trigger warning C4100 (unreferenced formal
|
|
||||||
// parameter) in MSVC with -W4. Unfortunately they cannot be fixed in
|
|
||||||
// the macro definition, as the warnings are generated when the macro
|
|
||||||
// is expanded and macro expansion cannot contain #pragma. Therefore
|
|
||||||
// we suppress them here.
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
# pragma warning(push)
|
|
||||||
# pragma warning(disable:4100)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Various overloads for InvokeArgument<N>().
|
|
||||||
//
|
|
||||||
// The InvokeArgument<N>(a1, a2, ..., a_k) action invokes the N-th
|
|
||||||
// (0-based) argument, which must be a k-ary callable, of the mock
|
|
||||||
// function, with arguments a1, a2, ..., a_k.
|
|
||||||
//
|
|
||||||
// Notes:
|
|
||||||
//
|
|
||||||
// 1. The arguments are passed by value by default. If you need to
|
|
||||||
// pass an argument by reference, wrap it inside ByRef(). For
|
|
||||||
// example,
|
|
||||||
//
|
|
||||||
// InvokeArgument<1>(5, string("Hello"), ByRef(foo))
|
|
||||||
//
|
|
||||||
// passes 5 and string("Hello") by value, and passes foo by
|
|
||||||
// reference.
|
|
||||||
//
|
|
||||||
// 2. If the callable takes an argument by reference but ByRef() is
|
|
||||||
// not used, it will receive the reference to a copy of the value,
|
|
||||||
// instead of the original value. For example, when the 0-th
|
|
||||||
// argument of the mock function takes a const string&, the action
|
|
||||||
//
|
|
||||||
// InvokeArgument<0>(string("Hello"))
|
|
||||||
//
|
|
||||||
// makes a copy of the temporary string("Hello") object and passes a
|
|
||||||
// reference of the copy, instead of the original temporary object,
|
|
||||||
// to the callable. This makes it easy for a user to define an
|
|
||||||
// InvokeArgument action from temporary values and have it performed
|
|
||||||
// later.
|
|
||||||
|
|
||||||
namespace internal {
|
|
||||||
namespace invoke_argument {
|
|
||||||
|
|
||||||
// Appears in InvokeArgumentAdl's argument list to help avoid
|
|
||||||
// accidental calls to user functions of the same name.
|
|
||||||
struct AdlTag {};
|
|
||||||
|
|
||||||
// InvokeArgumentAdl - a helper for InvokeArgument.
|
|
||||||
// The basic overloads are provided here for generic functors.
|
|
||||||
// Overloads for other custom-callables are provided in the
|
|
||||||
// internal/custom/callback-actions.h header.
|
|
||||||
|
|
||||||
$range i 0..n
|
|
||||||
$for i
|
|
||||||
[[
|
|
||||||
$range j 1..i
|
|
||||||
|
|
||||||
template <typename R, typename F[[$for j [[, typename A$j]]]]>
|
|
||||||
R InvokeArgumentAdl(AdlTag, F f[[$for j [[, A$j a$j]]]]) {
|
|
||||||
return f([[$for j, [[a$j]]]]);
|
|
||||||
}
|
|
||||||
]]
|
|
||||||
|
|
||||||
} // namespace invoke_argument
|
|
||||||
} // namespace internal
|
|
||||||
|
|
||||||
$range i 0..n
|
|
||||||
$for i [[
|
|
||||||
$range j 0..i-1
|
|
||||||
|
|
||||||
ACTION_TEMPLATE(InvokeArgument,
|
|
||||||
HAS_1_TEMPLATE_PARAMS(int, k),
|
|
||||||
AND_$i[[]]_VALUE_PARAMS($for j, [[p$j]])) {
|
|
||||||
using internal::invoke_argument::InvokeArgumentAdl;
|
|
||||||
return InvokeArgumentAdl<return_type>(
|
|
||||||
internal::invoke_argument::AdlTag(),
|
|
||||||
::testing::get<k>(args)$for j [[, p$j]]);
|
|
||||||
}
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
// Various overloads for ReturnNew<T>().
|
|
||||||
//
|
|
||||||
// The ReturnNew<T>(a1, a2, ..., a_k) action returns a pointer to a new
|
|
||||||
// instance of type T, constructed on the heap with constructor arguments
|
|
||||||
// a1, a2, ..., and a_k. The caller assumes ownership of the returned value.
|
|
||||||
$range i 0..n
|
|
||||||
$for i [[
|
|
||||||
$range j 0..i-1
|
|
||||||
$var ps = [[$for j, [[p$j]]]]
|
|
||||||
|
|
||||||
ACTION_TEMPLATE(ReturnNew,
|
|
||||||
HAS_1_TEMPLATE_PARAMS(typename, T),
|
|
||||||
AND_$i[[]]_VALUE_PARAMS($ps)) {
|
|
||||||
return new T($ps);
|
|
||||||
}
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
# pragma warning(pop)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace testing
|
|
||||||
|
|
||||||
// Include any custom callback actions added by the local installation.
|
|
||||||
// We must include this header at the end to make sure it can use the
|
|
||||||
// declarations from this file.
|
|
||||||
#include "gmock/internal/custom/gmock-generated-actions.h"
|
|
||||||
|
|
||||||
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,348 +0,0 @@
|
|||||||
$$ -*- mode: c++; -*-
|
|
||||||
$$ This is a Pump source file. Please use Pump to convert
|
|
||||||
$$ it to gmock-generated-function-mockers.h.
|
|
||||||
$$
|
|
||||||
$var n = 10 $$ The maximum arity we support.
|
|
||||||
// Copyright 2007, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
// Google Mock - a framework for writing C++ mock classes.
|
|
||||||
//
|
|
||||||
// This file implements function mockers of various arities.
|
|
||||||
|
|
||||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
|
||||||
|
|
||||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
|
|
||||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
|
|
||||||
|
|
||||||
#include "gmock/gmock-spec-builders.h"
|
|
||||||
#include "gmock/internal/gmock-internal-utils.h"
|
|
||||||
|
|
||||||
#if GTEST_HAS_STD_FUNCTION_
|
|
||||||
# include <functional>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace testing {
|
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
template <typename F>
|
|
||||||
class FunctionMockerBase;
|
|
||||||
|
|
||||||
// Note: class FunctionMocker really belongs to the ::testing
|
|
||||||
// namespace. However if we define it in ::testing, MSVC will
|
|
||||||
// complain when classes in ::testing::internal declare it as a
|
|
||||||
// friend class template. To workaround this compiler bug, we define
|
|
||||||
// FunctionMocker in ::testing::internal and import it into ::testing.
|
|
||||||
template <typename F>
|
|
||||||
class FunctionMocker;
|
|
||||||
|
|
||||||
|
|
||||||
$range i 0..n
|
|
||||||
$for i [[
|
|
||||||
$range j 1..i
|
|
||||||
$var typename_As = [[$for j [[, typename A$j]]]]
|
|
||||||
$var As = [[$for j, [[A$j]]]]
|
|
||||||
$var as = [[$for j, [[internal::forward<A$j>(a$j)]]]]
|
|
||||||
$var Aas = [[$for j, [[A$j a$j]]]]
|
|
||||||
$var ms = [[$for j, [[m$j]]]]
|
|
||||||
$var matchers = [[$for j, [[const Matcher<A$j>& m$j]]]]
|
|
||||||
template <typename R$typename_As>
|
|
||||||
class FunctionMocker<R($As)> : public
|
|
||||||
internal::FunctionMockerBase<R($As)> {
|
|
||||||
public:
|
|
||||||
typedef R F($As);
|
|
||||||
typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
|
|
||||||
|
|
||||||
MockSpec<F> With($matchers) {
|
|
||||||
return MockSpec<F>(this, ::testing::make_tuple($ms));
|
|
||||||
}
|
|
||||||
|
|
||||||
R Invoke($Aas) {
|
|
||||||
// Even though gcc and MSVC don't enforce it, 'this->' is required
|
|
||||||
// by the C++ standard [14.6.4] here, as the base class type is
|
|
||||||
// dependent on the template argument (and thus shouldn't be
|
|
||||||
// looked into when resolving InvokeWith).
|
|
||||||
return this->InvokeWith(ArgumentTuple($as));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
]]
|
|
||||||
// Removes the given pointer; this is a helper for the expectation setter method
|
|
||||||
// for parameterless matchers.
|
|
||||||
//
|
|
||||||
// We want to make sure that the user cannot set a parameterless expectation on
|
|
||||||
// overloaded methods, including methods which are overloaded on const. Example:
|
|
||||||
//
|
|
||||||
// class MockClass {
|
|
||||||
// MOCK_METHOD0(GetName, string&());
|
|
||||||
// MOCK_CONST_METHOD0(GetName, const string&());
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// TEST() {
|
|
||||||
// // This should be an error, as it's not clear which overload is expected.
|
|
||||||
// EXPECT_CALL(mock, GetName).WillOnce(ReturnRef(value));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Here are the generated expectation-setter methods:
|
|
||||||
//
|
|
||||||
// class MockClass {
|
|
||||||
// // Overload 1
|
|
||||||
// MockSpec<string&()> gmock_GetName() { ... }
|
|
||||||
// // Overload 2. Declared const so that the compiler will generate an
|
|
||||||
// // error when trying to resolve between this and overload 4 in
|
|
||||||
// // 'gmock_GetName(WithoutMatchers(), nullptr)'.
|
|
||||||
// MockSpec<string&()> gmock_GetName(
|
|
||||||
// const WithoutMatchers&, const Function<string&()>*) const {
|
|
||||||
// // Removes const from this, calls overload 1
|
|
||||||
// return AdjustConstness_(this)->gmock_GetName();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // Overload 3
|
|
||||||
// const string& gmock_GetName() const { ... }
|
|
||||||
// // Overload 4
|
|
||||||
// MockSpec<const string&()> gmock_GetName(
|
|
||||||
// const WithoutMatchers&, const Function<const string&()>*) const {
|
|
||||||
// // Does not remove const, calls overload 3
|
|
||||||
// return AdjustConstness_const(this)->gmock_GetName();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
template <typename MockType>
|
|
||||||
const MockType* AdjustConstness_const(const MockType* mock) {
|
|
||||||
return mock;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Removes const from and returns the given pointer; this is a helper for the
|
|
||||||
// expectation setter method for parameterless matchers.
|
|
||||||
template <typename MockType>
|
|
||||||
MockType* AdjustConstness_(const MockType* mock) {
|
|
||||||
return const_cast<MockType*>(mock);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
|
|
||||||
// The style guide prohibits "using" statements in a namespace scope
|
|
||||||
// inside a header file. However, the FunctionMocker class template
|
|
||||||
// is meant to be defined in the ::testing namespace. The following
|
|
||||||
// line is just a trick for working around a bug in MSVC 8.0, which
|
|
||||||
// cannot handle it if we define FunctionMocker in ::testing.
|
|
||||||
using internal::FunctionMocker;
|
|
||||||
|
|
||||||
// GMOCK_RESULT_(tn, F) expands to the result type of function type F.
|
|
||||||
// We define this as a variadic macro in case F contains unprotected
|
|
||||||
// commas (the same reason that we use variadic macros in other places
|
|
||||||
// in this file).
|
|
||||||
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
|
|
||||||
#define GMOCK_RESULT_(tn, ...) \
|
|
||||||
tn ::testing::internal::Function<__VA_ARGS__>::Result
|
|
||||||
|
|
||||||
// The type of argument N of the given function type.
|
|
||||||
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
|
|
||||||
#define GMOCK_ARG_(tn, N, ...) \
|
|
||||||
tn ::testing::internal::Function<__VA_ARGS__>::Argument##N
|
|
||||||
|
|
||||||
// The matcher type for argument N of the given function type.
|
|
||||||
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
|
|
||||||
#define GMOCK_MATCHER_(tn, N, ...) \
|
|
||||||
const ::testing::Matcher<GMOCK_ARG_(tn, N, __VA_ARGS__)>&
|
|
||||||
|
|
||||||
// The variable for mocking the given method.
|
|
||||||
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
|
|
||||||
#define GMOCK_MOCKER_(arity, constness, Method) \
|
|
||||||
GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__)
|
|
||||||
|
|
||||||
|
|
||||||
$for i [[
|
|
||||||
$range j 1..i
|
|
||||||
$var arg_as = [[$for j, [[GMOCK_ARG_(tn, $j, __VA_ARGS__) gmock_a$j]]]]
|
|
||||||
$var as = [[$for j, \
|
|
||||||
[[::testing::internal::forward<GMOCK_ARG_(tn, $j, __VA_ARGS__)>(gmock_a$j)]]]]
|
|
||||||
$var matcher_arg_as = [[$for j, \
|
|
||||||
[[GMOCK_MATCHER_(tn, $j, __VA_ARGS__) gmock_a$j]]]]
|
|
||||||
$var matcher_as = [[$for j, [[gmock_a$j]]]]
|
|
||||||
$var anything_matchers = [[$for j, \
|
|
||||||
[[::testing::A<GMOCK_ARG_(tn, $j, __VA_ARGS__)>()]]]]
|
|
||||||
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
|
|
||||||
#define GMOCK_METHOD$i[[]]_(tn, constness, ct, Method, ...) \
|
|
||||||
GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
|
|
||||||
$arg_as) constness { \
|
|
||||||
GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
|
|
||||||
tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value == $i), \
|
|
||||||
this_method_does_not_take_$i[[]]_argument[[$if i != 1 [[s]]]]); \
|
|
||||||
GMOCK_MOCKER_($i, constness, Method).SetOwnerAndName(this, #Method); \
|
|
||||||
return GMOCK_MOCKER_($i, constness, Method).Invoke($as); \
|
|
||||||
} \
|
|
||||||
::testing::MockSpec<__VA_ARGS__> \
|
|
||||||
gmock_##Method($matcher_arg_as) constness { \
|
|
||||||
GMOCK_MOCKER_($i, constness, Method).RegisterOwner(this); \
|
|
||||||
return GMOCK_MOCKER_($i, constness, Method).With($matcher_as); \
|
|
||||||
} \
|
|
||||||
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
|
|
||||||
const ::testing::internal::WithoutMatchers&, \
|
|
||||||
constness ::testing::internal::Function<__VA_ARGS__>* ) const { \
|
|
||||||
return ::testing::internal::AdjustConstness_##constness(this)-> \
|
|
||||||
gmock_##Method($anything_matchers); \
|
|
||||||
} \
|
|
||||||
mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_($i, constness, Method)
|
|
||||||
|
|
||||||
|
|
||||||
]]
|
|
||||||
$for i [[
|
|
||||||
#define MOCK_METHOD$i(m, ...) GMOCK_METHOD$i[[]]_(, , , m, __VA_ARGS__)
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
|
|
||||||
$for i [[
|
|
||||||
#define MOCK_CONST_METHOD$i(m, ...) GMOCK_METHOD$i[[]]_(, const, , m, __VA_ARGS__)
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
|
|
||||||
$for i [[
|
|
||||||
#define MOCK_METHOD$i[[]]_T(m, ...) GMOCK_METHOD$i[[]]_(typename, , , m, __VA_ARGS__)
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
|
|
||||||
$for i [[
|
|
||||||
#define MOCK_CONST_METHOD$i[[]]_T(m, ...) \
|
|
||||||
GMOCK_METHOD$i[[]]_(typename, const, , m, __VA_ARGS__)
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
|
|
||||||
$for i [[
|
|
||||||
#define MOCK_METHOD$i[[]]_WITH_CALLTYPE(ct, m, ...) \
|
|
||||||
GMOCK_METHOD$i[[]]_(, , ct, m, __VA_ARGS__)
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
|
|
||||||
$for i [[
|
|
||||||
#define MOCK_CONST_METHOD$i[[]]_WITH_CALLTYPE(ct, m, ...) \
|
|
||||||
GMOCK_METHOD$i[[]]_(, const, ct, m, __VA_ARGS__)
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
|
|
||||||
$for i [[
|
|
||||||
#define MOCK_METHOD$i[[]]_T_WITH_CALLTYPE(ct, m, ...) \
|
|
||||||
GMOCK_METHOD$i[[]]_(typename, , ct, m, __VA_ARGS__)
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
|
|
||||||
$for i [[
|
|
||||||
#define MOCK_CONST_METHOD$i[[]]_T_WITH_CALLTYPE(ct, m, ...) \
|
|
||||||
GMOCK_METHOD$i[[]]_(typename, const, ct, m, __VA_ARGS__)
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
// A MockFunction<F> class has one mock method whose type is F. It is
|
|
||||||
// useful when you just want your test code to emit some messages and
|
|
||||||
// have Google Mock verify the right messages are sent (and perhaps at
|
|
||||||
// the right times). For example, if you are exercising code:
|
|
||||||
//
|
|
||||||
// Foo(1);
|
|
||||||
// Foo(2);
|
|
||||||
// Foo(3);
|
|
||||||
//
|
|
||||||
// and want to verify that Foo(1) and Foo(3) both invoke
|
|
||||||
// mock.Bar("a"), but Foo(2) doesn't invoke anything, you can write:
|
|
||||||
//
|
|
||||||
// TEST(FooTest, InvokesBarCorrectly) {
|
|
||||||
// MyMock mock;
|
|
||||||
// MockFunction<void(string check_point_name)> check;
|
|
||||||
// {
|
|
||||||
// InSequence s;
|
|
||||||
//
|
|
||||||
// EXPECT_CALL(mock, Bar("a"));
|
|
||||||
// EXPECT_CALL(check, Call("1"));
|
|
||||||
// EXPECT_CALL(check, Call("2"));
|
|
||||||
// EXPECT_CALL(mock, Bar("a"));
|
|
||||||
// }
|
|
||||||
// Foo(1);
|
|
||||||
// check.Call("1");
|
|
||||||
// Foo(2);
|
|
||||||
// check.Call("2");
|
|
||||||
// Foo(3);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// The expectation spec says that the first Bar("a") must happen
|
|
||||||
// before check point "1", the second Bar("a") must happen after check
|
|
||||||
// point "2", and nothing should happen between the two check
|
|
||||||
// points. The explicit check points make it easy to tell which
|
|
||||||
// Bar("a") is called by which call to Foo().
|
|
||||||
//
|
|
||||||
// MockFunction<F> can also be used to exercise code that accepts
|
|
||||||
// std::function<F> callbacks. To do so, use AsStdFunction() method
|
|
||||||
// to create std::function proxy forwarding to original object's Call.
|
|
||||||
// Example:
|
|
||||||
//
|
|
||||||
// TEST(FooTest, RunsCallbackWithBarArgument) {
|
|
||||||
// MockFunction<int(string)> callback;
|
|
||||||
// EXPECT_CALL(callback, Call("bar")).WillOnce(Return(1));
|
|
||||||
// Foo(callback.AsStdFunction());
|
|
||||||
// }
|
|
||||||
template <typename F>
|
|
||||||
class MockFunction;
|
|
||||||
|
|
||||||
|
|
||||||
$for i [[
|
|
||||||
$range j 0..i-1
|
|
||||||
$var ArgTypes = [[$for j, [[A$j]]]]
|
|
||||||
$var ArgValues = [[$for j, [[::std::move(a$j)]]]]
|
|
||||||
$var ArgDecls = [[$for j, [[A$j a$j]]]]
|
|
||||||
template <typename R$for j [[, typename A$j]]>
|
|
||||||
class MockFunction<R($ArgTypes)> {
|
|
||||||
public:
|
|
||||||
MockFunction() {}
|
|
||||||
|
|
||||||
MOCK_METHOD$i[[]]_T(Call, R($ArgTypes));
|
|
||||||
|
|
||||||
#if GTEST_HAS_STD_FUNCTION_
|
|
||||||
::std::function<R($ArgTypes)> AsStdFunction() {
|
|
||||||
return [this]($ArgDecls) -> R {
|
|
||||||
return this->Call($ArgValues);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#endif // GTEST_HAS_STD_FUNCTION_
|
|
||||||
|
|
||||||
private:
|
|
||||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
]]
|
|
||||||
} // namespace testing
|
|
||||||
|
|
||||||
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,678 +0,0 @@
|
|||||||
$$ -*- mode: c++; -*-
|
|
||||||
$$ This is a Pump source file. Please use Pump to convert
|
|
||||||
$$ it to gmock-generated-matchers.h.
|
|
||||||
$$
|
|
||||||
$var n = 10 $$ The maximum arity we support.
|
|
||||||
$$ }} This line fixes auto-indentation of the following code in Emacs.
|
|
||||||
// Copyright 2008, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
// Google Mock - a framework for writing C++ mock classes.
|
|
||||||
//
|
|
||||||
// This file implements some commonly used variadic matchers.
|
|
||||||
|
|
||||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
|
||||||
|
|
||||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
|
|
||||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
|
|
||||||
|
|
||||||
#include <iterator>
|
|
||||||
#include <sstream>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include "gmock/gmock-matchers.h"
|
|
||||||
|
|
||||||
namespace testing {
|
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
$range i 0..n-1
|
|
||||||
|
|
||||||
// The type of the i-th (0-based) field of Tuple.
|
|
||||||
#define GMOCK_FIELD_TYPE_(Tuple, i) \
|
|
||||||
typename ::testing::tuple_element<i, Tuple>::type
|
|
||||||
|
|
||||||
// TupleFields<Tuple, k0, ..., kn> is for selecting fields from a
|
|
||||||
// tuple of type Tuple. It has two members:
|
|
||||||
//
|
|
||||||
// type: a tuple type whose i-th field is the ki-th field of Tuple.
|
|
||||||
// GetSelectedFields(t): returns fields k0, ..., and kn of t as a tuple.
|
|
||||||
//
|
|
||||||
// For example, in class TupleFields<tuple<bool, char, int>, 2, 0>, we have:
|
|
||||||
//
|
|
||||||
// type is tuple<int, bool>, and
|
|
||||||
// GetSelectedFields(make_tuple(true, 'a', 42)) is (42, true).
|
|
||||||
|
|
||||||
template <class Tuple$for i [[, int k$i = -1]]>
|
|
||||||
class TupleFields;
|
|
||||||
|
|
||||||
// This generic version is used when there are $n selectors.
|
|
||||||
template <class Tuple$for i [[, int k$i]]>
|
|
||||||
class TupleFields {
|
|
||||||
public:
|
|
||||||
typedef ::testing::tuple<$for i, [[GMOCK_FIELD_TYPE_(Tuple, k$i)]]> type;
|
|
||||||
static type GetSelectedFields(const Tuple& t) {
|
|
||||||
return type($for i, [[get<k$i>(t)]]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// The following specialization is used for 0 ~ $(n-1) selectors.
|
|
||||||
|
|
||||||
$for i [[
|
|
||||||
$$ }}}
|
|
||||||
$range j 0..i-1
|
|
||||||
$range k 0..n-1
|
|
||||||
|
|
||||||
template <class Tuple$for j [[, int k$j]]>
|
|
||||||
class TupleFields<Tuple, $for k, [[$if k < i [[k$k]] $else [[-1]]]]> {
|
|
||||||
public:
|
|
||||||
typedef ::testing::tuple<$for j, [[GMOCK_FIELD_TYPE_(Tuple, k$j)]]> type;
|
|
||||||
static type GetSelectedFields(const Tuple& $if i==0 [[/* t */]] $else [[t]]) {
|
|
||||||
return type($for j, [[get<k$j>(t)]]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
#undef GMOCK_FIELD_TYPE_
|
|
||||||
|
|
||||||
// Implements the Args() matcher.
|
|
||||||
|
|
||||||
$var ks = [[$for i, [[k$i]]]]
|
|
||||||
template <class ArgsTuple$for i [[, int k$i = -1]]>
|
|
||||||
class ArgsMatcherImpl : public MatcherInterface<ArgsTuple> {
|
|
||||||
public:
|
|
||||||
// ArgsTuple may have top-level const or reference modifiers.
|
|
||||||
typedef GTEST_REMOVE_REFERENCE_AND_CONST_(ArgsTuple) RawArgsTuple;
|
|
||||||
typedef typename internal::TupleFields<RawArgsTuple, $ks>::type SelectedArgs;
|
|
||||||
typedef Matcher<const SelectedArgs&> MonomorphicInnerMatcher;
|
|
||||||
|
|
||||||
template <typename InnerMatcher>
|
|
||||||
explicit ArgsMatcherImpl(const InnerMatcher& inner_matcher)
|
|
||||||
: inner_matcher_(SafeMatcherCast<const SelectedArgs&>(inner_matcher)) {}
|
|
||||||
|
|
||||||
virtual bool MatchAndExplain(ArgsTuple args,
|
|
||||||
MatchResultListener* listener) const {
|
|
||||||
const SelectedArgs& selected_args = GetSelectedArgs(args);
|
|
||||||
if (!listener->IsInterested())
|
|
||||||
return inner_matcher_.Matches(selected_args);
|
|
||||||
|
|
||||||
PrintIndices(listener->stream());
|
|
||||||
*listener << "are " << PrintToString(selected_args);
|
|
||||||
|
|
||||||
StringMatchResultListener inner_listener;
|
|
||||||
const bool match = inner_matcher_.MatchAndExplain(selected_args,
|
|
||||||
&inner_listener);
|
|
||||||
PrintIfNotEmpty(inner_listener.str(), listener->stream());
|
|
||||||
return match;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void DescribeTo(::std::ostream* os) const {
|
|
||||||
*os << "are a tuple ";
|
|
||||||
PrintIndices(os);
|
|
||||||
inner_matcher_.DescribeTo(os);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void DescribeNegationTo(::std::ostream* os) const {
|
|
||||||
*os << "are a tuple ";
|
|
||||||
PrintIndices(os);
|
|
||||||
inner_matcher_.DescribeNegationTo(os);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
static SelectedArgs GetSelectedArgs(ArgsTuple args) {
|
|
||||||
return TupleFields<RawArgsTuple, $ks>::GetSelectedFields(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prints the indices of the selected fields.
|
|
||||||
static void PrintIndices(::std::ostream* os) {
|
|
||||||
*os << "whose fields (";
|
|
||||||
const int indices[$n] = { $ks };
|
|
||||||
for (int i = 0; i < $n; i++) {
|
|
||||||
if (indices[i] < 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (i >= 1)
|
|
||||||
*os << ", ";
|
|
||||||
|
|
||||||
*os << "#" << indices[i];
|
|
||||||
}
|
|
||||||
*os << ") ";
|
|
||||||
}
|
|
||||||
|
|
||||||
const MonomorphicInnerMatcher inner_matcher_;
|
|
||||||
|
|
||||||
GTEST_DISALLOW_ASSIGN_(ArgsMatcherImpl);
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class InnerMatcher$for i [[, int k$i = -1]]>
|
|
||||||
class ArgsMatcher {
|
|
||||||
public:
|
|
||||||
explicit ArgsMatcher(const InnerMatcher& inner_matcher)
|
|
||||||
: inner_matcher_(inner_matcher) {}
|
|
||||||
|
|
||||||
template <typename ArgsTuple>
|
|
||||||
operator Matcher<ArgsTuple>() const {
|
|
||||||
return MakeMatcher(new ArgsMatcherImpl<ArgsTuple, $ks>(inner_matcher_));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
const InnerMatcher inner_matcher_;
|
|
||||||
|
|
||||||
GTEST_DISALLOW_ASSIGN_(ArgsMatcher);
|
|
||||||
};
|
|
||||||
|
|
||||||
// A set of metafunctions for computing the result type of AllOf.
|
|
||||||
// AllOf(m1, ..., mN) returns
|
|
||||||
// AllOfResultN<decltype(m1), ..., decltype(mN)>::type.
|
|
||||||
|
|
||||||
// Although AllOf isn't defined for one argument, AllOfResult1 is defined
|
|
||||||
// to simplify the implementation.
|
|
||||||
template <typename M1>
|
|
||||||
struct AllOfResult1 {
|
|
||||||
typedef M1 type;
|
|
||||||
};
|
|
||||||
|
|
||||||
$range i 1..n
|
|
||||||
|
|
||||||
$range i 2..n
|
|
||||||
$for i [[
|
|
||||||
$range j 2..i
|
|
||||||
$var m = i/2
|
|
||||||
$range k 1..m
|
|
||||||
$range t m+1..i
|
|
||||||
|
|
||||||
template <typename M1$for j [[, typename M$j]]>
|
|
||||||
struct AllOfResult$i {
|
|
||||||
typedef BothOfMatcher<
|
|
||||||
typename AllOfResult$m<$for k, [[M$k]]>::type,
|
|
||||||
typename AllOfResult$(i-m)<$for t, [[M$t]]>::type
|
|
||||||
> type;
|
|
||||||
};
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
// A set of metafunctions for computing the result type of AnyOf.
|
|
||||||
// AnyOf(m1, ..., mN) returns
|
|
||||||
// AnyOfResultN<decltype(m1), ..., decltype(mN)>::type.
|
|
||||||
|
|
||||||
// Although AnyOf isn't defined for one argument, AnyOfResult1 is defined
|
|
||||||
// to simplify the implementation.
|
|
||||||
template <typename M1>
|
|
||||||
struct AnyOfResult1 {
|
|
||||||
typedef M1 type;
|
|
||||||
};
|
|
||||||
|
|
||||||
$range i 1..n
|
|
||||||
|
|
||||||
$range i 2..n
|
|
||||||
$for i [[
|
|
||||||
$range j 2..i
|
|
||||||
$var m = i/2
|
|
||||||
$range k 1..m
|
|
||||||
$range t m+1..i
|
|
||||||
|
|
||||||
template <typename M1$for j [[, typename M$j]]>
|
|
||||||
struct AnyOfResult$i {
|
|
||||||
typedef EitherOfMatcher<
|
|
||||||
typename AnyOfResult$m<$for k, [[M$k]]>::type,
|
|
||||||
typename AnyOfResult$(i-m)<$for t, [[M$t]]>::type
|
|
||||||
> type;
|
|
||||||
};
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
|
|
||||||
// Args<N1, N2, ..., Nk>(a_matcher) matches a tuple if the selected
|
|
||||||
// fields of it matches a_matcher. C++ doesn't support default
|
|
||||||
// arguments for function templates, so we have to overload it.
|
|
||||||
|
|
||||||
$range i 0..n
|
|
||||||
$for i [[
|
|
||||||
$range j 1..i
|
|
||||||
template <$for j [[int k$j, ]]typename InnerMatcher>
|
|
||||||
inline internal::ArgsMatcher<InnerMatcher$for j [[, k$j]]>
|
|
||||||
Args(const InnerMatcher& matcher) {
|
|
||||||
return internal::ArgsMatcher<InnerMatcher$for j [[, k$j]]>(matcher);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
]]
|
|
||||||
// ElementsAre(e_1, e_2, ... e_n) matches an STL-style container with
|
|
||||||
// n elements, where the i-th element in the container must
|
|
||||||
// match the i-th argument in the list. Each argument of
|
|
||||||
// ElementsAre() can be either a value or a matcher. We support up to
|
|
||||||
// $n arguments.
|
|
||||||
//
|
|
||||||
// The use of DecayArray in the implementation allows ElementsAre()
|
|
||||||
// to accept string literals, whose type is const char[N], but we
|
|
||||||
// want to treat them as const char*.
|
|
||||||
//
|
|
||||||
// NOTE: Since ElementsAre() cares about the order of the elements, it
|
|
||||||
// must not be used with containers whose elements's order is
|
|
||||||
// undefined (e.g. hash_map).
|
|
||||||
|
|
||||||
$range i 0..n
|
|
||||||
$for i [[
|
|
||||||
|
|
||||||
$range j 1..i
|
|
||||||
|
|
||||||
$if i>0 [[
|
|
||||||
|
|
||||||
template <$for j, [[typename T$j]]>
|
|
||||||
]]
|
|
||||||
|
|
||||||
inline internal::ElementsAreMatcher<
|
|
||||||
::testing::tuple<
|
|
||||||
$for j, [[
|
|
||||||
|
|
||||||
typename internal::DecayArray<T$j[[]]>::type]]> >
|
|
||||||
ElementsAre($for j, [[const T$j& e$j]]) {
|
|
||||||
typedef ::testing::tuple<
|
|
||||||
$for j, [[
|
|
||||||
|
|
||||||
typename internal::DecayArray<T$j[[]]>::type]]> Args;
|
|
||||||
return internal::ElementsAreMatcher<Args>(Args($for j, [[e$j]]));
|
|
||||||
}
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
// UnorderedElementsAre(e_1, e_2, ..., e_n) is an ElementsAre extension
|
|
||||||
// that matches n elements in any order. We support up to n=$n arguments.
|
|
||||||
//
|
|
||||||
// If you have >$n elements, consider UnorderedElementsAreArray() or
|
|
||||||
// UnorderedPointwise() instead.
|
|
||||||
|
|
||||||
$range i 0..n
|
|
||||||
$for i [[
|
|
||||||
|
|
||||||
$range j 1..i
|
|
||||||
|
|
||||||
$if i>0 [[
|
|
||||||
|
|
||||||
template <$for j, [[typename T$j]]>
|
|
||||||
]]
|
|
||||||
|
|
||||||
inline internal::UnorderedElementsAreMatcher<
|
|
||||||
::testing::tuple<
|
|
||||||
$for j, [[
|
|
||||||
|
|
||||||
typename internal::DecayArray<T$j[[]]>::type]]> >
|
|
||||||
UnorderedElementsAre($for j, [[const T$j& e$j]]) {
|
|
||||||
typedef ::testing::tuple<
|
|
||||||
$for j, [[
|
|
||||||
|
|
||||||
typename internal::DecayArray<T$j[[]]>::type]]> Args;
|
|
||||||
return internal::UnorderedElementsAreMatcher<Args>(Args($for j, [[e$j]]));
|
|
||||||
}
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
// AllOf(m1, m2, ..., mk) matches any value that matches all of the given
|
|
||||||
// sub-matchers. AllOf is called fully qualified to prevent ADL from firing.
|
|
||||||
|
|
||||||
$range i 2..n
|
|
||||||
$for i [[
|
|
||||||
$range j 1..i
|
|
||||||
$var m = i/2
|
|
||||||
$range k 1..m
|
|
||||||
$range t m+1..i
|
|
||||||
|
|
||||||
template <$for j, [[typename M$j]]>
|
|
||||||
inline typename internal::AllOfResult$i<$for j, [[M$j]]>::type
|
|
||||||
AllOf($for j, [[M$j m$j]]) {
|
|
||||||
return typename internal::AllOfResult$i<$for j, [[M$j]]>::type(
|
|
||||||
$if m == 1 [[m1]] $else [[::testing::AllOf($for k, [[m$k]])]],
|
|
||||||
$if m+1 == i [[m$i]] $else [[::testing::AllOf($for t, [[m$t]])]]);
|
|
||||||
}
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
// AnyOf(m1, m2, ..., mk) matches any value that matches any of the given
|
|
||||||
// sub-matchers. AnyOf is called fully qualified to prevent ADL from firing.
|
|
||||||
|
|
||||||
$range i 2..n
|
|
||||||
$for i [[
|
|
||||||
$range j 1..i
|
|
||||||
$var m = i/2
|
|
||||||
$range k 1..m
|
|
||||||
$range t m+1..i
|
|
||||||
|
|
||||||
template <$for j, [[typename M$j]]>
|
|
||||||
inline typename internal::AnyOfResult$i<$for j, [[M$j]]>::type
|
|
||||||
AnyOf($for j, [[M$j m$j]]) {
|
|
||||||
return typename internal::AnyOfResult$i<$for j, [[M$j]]>::type(
|
|
||||||
$if m == 1 [[m1]] $else [[::testing::AnyOf($for k, [[m$k]])]],
|
|
||||||
$if m+1 == i [[m$i]] $else [[::testing::AnyOf($for t, [[m$t]])]]);
|
|
||||||
}
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
} // namespace testing
|
|
||||||
$$ } // This Pump meta comment fixes auto-indentation in Emacs. It will not
|
|
||||||
$$ // show up in the generated code.
|
|
||||||
|
|
||||||
|
|
||||||
// The MATCHER* family of macros can be used in a namespace scope to
|
|
||||||
// define custom matchers easily.
|
|
||||||
//
|
|
||||||
// Basic Usage
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// The syntax
|
|
||||||
//
|
|
||||||
// MATCHER(name, description_string) { statements; }
|
|
||||||
//
|
|
||||||
// defines a matcher with the given name that executes the statements,
|
|
||||||
// which must return a bool to indicate if the match succeeds. Inside
|
|
||||||
// the statements, you can refer to the value being matched by 'arg',
|
|
||||||
// and refer to its type by 'arg_type'.
|
|
||||||
//
|
|
||||||
// The description string documents what the matcher does, and is used
|
|
||||||
// to generate the failure message when the match fails. Since a
|
|
||||||
// MATCHER() is usually defined in a header file shared by multiple
|
|
||||||
// C++ source files, we require the description to be a C-string
|
|
||||||
// literal to avoid possible side effects. It can be empty, in which
|
|
||||||
// case we'll use the sequence of words in the matcher name as the
|
|
||||||
// description.
|
|
||||||
//
|
|
||||||
// For example:
|
|
||||||
//
|
|
||||||
// MATCHER(IsEven, "") { return (arg % 2) == 0; }
|
|
||||||
//
|
|
||||||
// allows you to write
|
|
||||||
//
|
|
||||||
// // Expects mock_foo.Bar(n) to be called where n is even.
|
|
||||||
// EXPECT_CALL(mock_foo, Bar(IsEven()));
|
|
||||||
//
|
|
||||||
// or,
|
|
||||||
//
|
|
||||||
// // Verifies that the value of some_expression is even.
|
|
||||||
// EXPECT_THAT(some_expression, IsEven());
|
|
||||||
//
|
|
||||||
// If the above assertion fails, it will print something like:
|
|
||||||
//
|
|
||||||
// Value of: some_expression
|
|
||||||
// Expected: is even
|
|
||||||
// Actual: 7
|
|
||||||
//
|
|
||||||
// where the description "is even" is automatically calculated from the
|
|
||||||
// matcher name IsEven.
|
|
||||||
//
|
|
||||||
// Argument Type
|
|
||||||
// =============
|
|
||||||
//
|
|
||||||
// Note that the type of the value being matched (arg_type) is
|
|
||||||
// determined by the context in which you use the matcher and is
|
|
||||||
// supplied to you by the compiler, so you don't need to worry about
|
|
||||||
// declaring it (nor can you). This allows the matcher to be
|
|
||||||
// polymorphic. For example, IsEven() can be used to match any type
|
|
||||||
// where the value of "(arg % 2) == 0" can be implicitly converted to
|
|
||||||
// a bool. In the "Bar(IsEven())" example above, if method Bar()
|
|
||||||
// takes an int, 'arg_type' will be int; if it takes an unsigned long,
|
|
||||||
// 'arg_type' will be unsigned long; and so on.
|
|
||||||
//
|
|
||||||
// Parameterizing Matchers
|
|
||||||
// =======================
|
|
||||||
//
|
|
||||||
// Sometimes you'll want to parameterize the matcher. For that you
|
|
||||||
// can use another macro:
|
|
||||||
//
|
|
||||||
// MATCHER_P(name, param_name, description_string) { statements; }
|
|
||||||
//
|
|
||||||
// For example:
|
|
||||||
//
|
|
||||||
// MATCHER_P(HasAbsoluteValue, value, "") { return abs(arg) == value; }
|
|
||||||
//
|
|
||||||
// will allow you to write:
|
|
||||||
//
|
|
||||||
// EXPECT_THAT(Blah("a"), HasAbsoluteValue(n));
|
|
||||||
//
|
|
||||||
// which may lead to this message (assuming n is 10):
|
|
||||||
//
|
|
||||||
// Value of: Blah("a")
|
|
||||||
// Expected: has absolute value 10
|
|
||||||
// Actual: -9
|
|
||||||
//
|
|
||||||
// Note that both the matcher description and its parameter are
|
|
||||||
// printed, making the message human-friendly.
|
|
||||||
//
|
|
||||||
// In the matcher definition body, you can write 'foo_type' to
|
|
||||||
// reference the type of a parameter named 'foo'. For example, in the
|
|
||||||
// body of MATCHER_P(HasAbsoluteValue, value) above, you can write
|
|
||||||
// 'value_type' to refer to the type of 'value'.
|
|
||||||
//
|
|
||||||
// We also provide MATCHER_P2, MATCHER_P3, ..., up to MATCHER_P$n to
|
|
||||||
// support multi-parameter matchers.
|
|
||||||
//
|
|
||||||
// Describing Parameterized Matchers
|
|
||||||
// =================================
|
|
||||||
//
|
|
||||||
// The last argument to MATCHER*() is a string-typed expression. The
|
|
||||||
// expression can reference all of the matcher's parameters and a
|
|
||||||
// special bool-typed variable named 'negation'. When 'negation' is
|
|
||||||
// false, the expression should evaluate to the matcher's description;
|
|
||||||
// otherwise it should evaluate to the description of the negation of
|
|
||||||
// the matcher. For example,
|
|
||||||
//
|
|
||||||
// using testing::PrintToString;
|
|
||||||
//
|
|
||||||
// MATCHER_P2(InClosedRange, low, hi,
|
|
||||||
// std::string(negation ? "is not" : "is") + " in range [" +
|
|
||||||
// PrintToString(low) + ", " + PrintToString(hi) + "]") {
|
|
||||||
// return low <= arg && arg <= hi;
|
|
||||||
// }
|
|
||||||
// ...
|
|
||||||
// EXPECT_THAT(3, InClosedRange(4, 6));
|
|
||||||
// EXPECT_THAT(3, Not(InClosedRange(2, 4)));
|
|
||||||
//
|
|
||||||
// would generate two failures that contain the text:
|
|
||||||
//
|
|
||||||
// Expected: is in range [4, 6]
|
|
||||||
// ...
|
|
||||||
// Expected: is not in range [2, 4]
|
|
||||||
//
|
|
||||||
// If you specify "" as the description, the failure message will
|
|
||||||
// contain the sequence of words in the matcher name followed by the
|
|
||||||
// parameter values printed as a tuple. For example,
|
|
||||||
//
|
|
||||||
// MATCHER_P2(InClosedRange, low, hi, "") { ... }
|
|
||||||
// ...
|
|
||||||
// EXPECT_THAT(3, InClosedRange(4, 6));
|
|
||||||
// EXPECT_THAT(3, Not(InClosedRange(2, 4)));
|
|
||||||
//
|
|
||||||
// would generate two failures that contain the text:
|
|
||||||
//
|
|
||||||
// Expected: in closed range (4, 6)
|
|
||||||
// ...
|
|
||||||
// Expected: not (in closed range (2, 4))
|
|
||||||
//
|
|
||||||
// Types of Matcher Parameters
|
|
||||||
// ===========================
|
|
||||||
//
|
|
||||||
// For the purpose of typing, you can view
|
|
||||||
//
|
|
||||||
// MATCHER_Pk(Foo, p1, ..., pk, description_string) { ... }
|
|
||||||
//
|
|
||||||
// as shorthand for
|
|
||||||
//
|
|
||||||
// template <typename p1_type, ..., typename pk_type>
|
|
||||||
// FooMatcherPk<p1_type, ..., pk_type>
|
|
||||||
// Foo(p1_type p1, ..., pk_type pk) { ... }
|
|
||||||
//
|
|
||||||
// When you write Foo(v1, ..., vk), the compiler infers the types of
|
|
||||||
// the parameters v1, ..., and vk for you. If you are not happy with
|
|
||||||
// the result of the type inference, you can specify the types by
|
|
||||||
// explicitly instantiating the template, as in Foo<long, bool>(5,
|
|
||||||
// false). As said earlier, you don't get to (or need to) specify
|
|
||||||
// 'arg_type' as that's determined by the context in which the matcher
|
|
||||||
// is used. You can assign the result of expression Foo(p1, ..., pk)
|
|
||||||
// to a variable of type FooMatcherPk<p1_type, ..., pk_type>. This
|
|
||||||
// can be useful when composing matchers.
|
|
||||||
//
|
|
||||||
// While you can instantiate a matcher template with reference types,
|
|
||||||
// passing the parameters by pointer usually makes your code more
|
|
||||||
// readable. If, however, you still want to pass a parameter by
|
|
||||||
// reference, be aware that in the failure message generated by the
|
|
||||||
// matcher you will see the value of the referenced object but not its
|
|
||||||
// address.
|
|
||||||
//
|
|
||||||
// Explaining Match Results
|
|
||||||
// ========================
|
|
||||||
//
|
|
||||||
// Sometimes the matcher description alone isn't enough to explain why
|
|
||||||
// the match has failed or succeeded. For example, when expecting a
|
|
||||||
// long string, it can be very helpful to also print the diff between
|
|
||||||
// the expected string and the actual one. To achieve that, you can
|
|
||||||
// optionally stream additional information to a special variable
|
|
||||||
// named result_listener, whose type is a pointer to class
|
|
||||||
// MatchResultListener:
|
|
||||||
//
|
|
||||||
// MATCHER_P(EqualsLongString, str, "") {
|
|
||||||
// if (arg == str) return true;
|
|
||||||
//
|
|
||||||
// *result_listener << "the difference: "
|
|
||||||
/// << DiffStrings(str, arg);
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Overloading Matchers
|
|
||||||
// ====================
|
|
||||||
//
|
|
||||||
// You can overload matchers with different numbers of parameters:
|
|
||||||
//
|
|
||||||
// MATCHER_P(Blah, a, description_string1) { ... }
|
|
||||||
// MATCHER_P2(Blah, a, b, description_string2) { ... }
|
|
||||||
//
|
|
||||||
// Caveats
|
|
||||||
// =======
|
|
||||||
//
|
|
||||||
// When defining a new matcher, you should also consider implementing
|
|
||||||
// MatcherInterface or using MakePolymorphicMatcher(). These
|
|
||||||
// approaches require more work than the MATCHER* macros, but also
|
|
||||||
// give you more control on the types of the value being matched and
|
|
||||||
// the matcher parameters, which may leads to better compiler error
|
|
||||||
// messages when the matcher is used wrong. They also allow
|
|
||||||
// overloading matchers based on parameter types (as opposed to just
|
|
||||||
// based on the number of parameters).
|
|
||||||
//
|
|
||||||
// MATCHER*() can only be used in a namespace scope. The reason is
|
|
||||||
// that C++ doesn't yet allow function-local types to be used to
|
|
||||||
// instantiate templates. The up-coming C++0x standard will fix this.
|
|
||||||
// Once that's done, we'll consider supporting using MATCHER*() inside
|
|
||||||
// a function.
|
|
||||||
//
|
|
||||||
// More Information
|
|
||||||
// ================
|
|
||||||
//
|
|
||||||
// To learn more about using these macros, please search for 'MATCHER'
|
|
||||||
// on
|
|
||||||
// https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md
|
|
||||||
|
|
||||||
$range i 0..n
|
|
||||||
$for i
|
|
||||||
|
|
||||||
[[
|
|
||||||
$var macro_name = [[$if i==0 [[MATCHER]] $elif i==1 [[MATCHER_P]]
|
|
||||||
$else [[MATCHER_P$i]]]]
|
|
||||||
$var class_name = [[name##Matcher[[$if i==0 [[]] $elif i==1 [[P]]
|
|
||||||
$else [[P$i]]]]]]
|
|
||||||
$range j 0..i-1
|
|
||||||
$var template = [[$if i==0 [[]] $else [[
|
|
||||||
|
|
||||||
template <$for j, [[typename p$j##_type]]>\
|
|
||||||
]]]]
|
|
||||||
$var ctor_param_list = [[$for j, [[p$j##_type gmock_p$j]]]]
|
|
||||||
$var impl_ctor_param_list = [[$for j, [[p$j##_type gmock_p$j]]]]
|
|
||||||
$var impl_inits = [[$if i==0 [[]] $else [[ : $for j, [[p$j(::testing::internal::move(gmock_p$j))]]]]]]
|
|
||||||
$var inits = [[$if i==0 [[]] $else [[ : $for j, [[p$j(::testing::internal::move(gmock_p$j))]]]]]]
|
|
||||||
$var params = [[$for j, [[p$j]]]]
|
|
||||||
$var param_types = [[$if i==0 [[]] $else [[<$for j, [[p$j##_type]]>]]]]
|
|
||||||
$var param_types_and_names = [[$for j, [[p$j##_type p$j]]]]
|
|
||||||
$var param_field_decls = [[$for j
|
|
||||||
[[
|
|
||||||
|
|
||||||
p$j##_type const p$j;\
|
|
||||||
]]]]
|
|
||||||
$var param_field_decls2 = [[$for j
|
|
||||||
[[
|
|
||||||
|
|
||||||
p$j##_type const p$j;\
|
|
||||||
]]]]
|
|
||||||
|
|
||||||
#define $macro_name(name$for j [[, p$j]], description)\$template
|
|
||||||
class $class_name {\
|
|
||||||
public:\
|
|
||||||
template <typename arg_type>\
|
|
||||||
class gmock_Impl : public ::testing::MatcherInterface<\
|
|
||||||
GTEST_REFERENCE_TO_CONST_(arg_type)> {\
|
|
||||||
public:\
|
|
||||||
[[$if i==1 [[explicit ]]]]gmock_Impl($impl_ctor_param_list)\
|
|
||||||
$impl_inits {}\
|
|
||||||
virtual bool MatchAndExplain(\
|
|
||||||
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
|
|
||||||
::testing::MatchResultListener* result_listener) const;\
|
|
||||||
virtual void DescribeTo(::std::ostream* gmock_os) const {\
|
|
||||||
*gmock_os << FormatDescription(false);\
|
|
||||||
}\
|
|
||||||
virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
|
|
||||||
*gmock_os << FormatDescription(true);\
|
|
||||||
}\$param_field_decls
|
|
||||||
private:\
|
|
||||||
::std::string FormatDescription(bool negation) const {\
|
|
||||||
::std::string gmock_description = (description);\
|
|
||||||
if (!gmock_description.empty())\
|
|
||||||
return gmock_description;\
|
|
||||||
return ::testing::internal::FormatMatcherDescription(\
|
|
||||||
negation, #name, \
|
|
||||||
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
|
|
||||||
::testing::tuple<$for j, [[p$j##_type]]>($for j, [[p$j]])));\
|
|
||||||
}\
|
|
||||||
};\
|
|
||||||
template <typename arg_type>\
|
|
||||||
operator ::testing::Matcher<arg_type>() const {\
|
|
||||||
return ::testing::Matcher<arg_type>(\
|
|
||||||
new gmock_Impl<arg_type>($params));\
|
|
||||||
}\
|
|
||||||
[[$if i==1 [[explicit ]]]]$class_name($ctor_param_list)$inits {\
|
|
||||||
}\$param_field_decls2
|
|
||||||
private:\
|
|
||||||
};\$template
|
|
||||||
inline $class_name$param_types name($param_types_and_names) {\
|
|
||||||
return $class_name$param_types($params);\
|
|
||||||
}\$template
|
|
||||||
template <typename arg_type>\
|
|
||||||
bool $class_name$param_types::gmock_Impl<arg_type>::MatchAndExplain(\
|
|
||||||
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
|
|
||||||
::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
|
|
||||||
const
|
|
||||||
]]
|
|
||||||
|
|
||||||
|
|
||||||
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
|
|
||||||
@@ -1,459 +0,0 @@
|
|||||||
// This file was GENERATED by command:
|
|
||||||
// pump.py gmock-generated-nice-strict.h.pump
|
|
||||||
// DO NOT EDIT BY HAND!!!
|
|
||||||
|
|
||||||
// Copyright 2008, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
// Implements class templates NiceMock, NaggyMock, and StrictMock.
|
|
||||||
//
|
|
||||||
// Given a mock class MockFoo that is created using Google Mock,
|
|
||||||
// NiceMock<MockFoo> is a subclass of MockFoo that allows
|
|
||||||
// uninteresting calls (i.e. calls to mock methods that have no
|
|
||||||
// EXPECT_CALL specs), NaggyMock<MockFoo> is a subclass of MockFoo
|
|
||||||
// that prints a warning when an uninteresting call occurs, and
|
|
||||||
// StrictMock<MockFoo> is a subclass of MockFoo that treats all
|
|
||||||
// uninteresting calls as errors.
|
|
||||||
//
|
|
||||||
// Currently a mock is naggy by default, so MockFoo and
|
|
||||||
// NaggyMock<MockFoo> behave like the same. However, we will soon
|
|
||||||
// switch the default behavior of mocks to be nice, as that in general
|
|
||||||
// leads to more maintainable tests. When that happens, MockFoo will
|
|
||||||
// stop behaving like NaggyMock<MockFoo> and start behaving like
|
|
||||||
// NiceMock<MockFoo>.
|
|
||||||
//
|
|
||||||
// NiceMock, NaggyMock, and StrictMock "inherit" the constructors of
|
|
||||||
// their respective base class. Therefore you can write
|
|
||||||
// NiceMock<MockFoo>(5, "a") to construct a nice mock where MockFoo
|
|
||||||
// has a constructor that accepts (int, const char*), for example.
|
|
||||||
//
|
|
||||||
// A known limitation is that NiceMock<MockFoo>, NaggyMock<MockFoo>,
|
|
||||||
// and StrictMock<MockFoo> only works for mock methods defined using
|
|
||||||
// the MOCK_METHOD* family of macros DIRECTLY in the MockFoo class.
|
|
||||||
// If a mock method is defined in a base class of MockFoo, the "nice"
|
|
||||||
// or "strict" modifier may not affect it, depending on the compiler.
|
|
||||||
// In particular, nesting NiceMock, NaggyMock, and StrictMock is NOT
|
|
||||||
// supported.
|
|
||||||
|
|
||||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
|
||||||
|
|
||||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
|
|
||||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
|
|
||||||
|
|
||||||
#include "gmock/gmock-spec-builders.h"
|
|
||||||
#include "gmock/internal/gmock-port.h"
|
|
||||||
|
|
||||||
namespace testing {
|
|
||||||
|
|
||||||
template <class MockClass>
|
|
||||||
class NiceMock : public MockClass {
|
|
||||||
public:
|
|
||||||
NiceMock() : MockClass() {
|
|
||||||
::testing::Mock::AllowUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
#if GTEST_LANG_CXX11
|
|
||||||
// Ideally, we would inherit base class's constructors through a using
|
|
||||||
// declaration, which would preserve their visibility. However, many existing
|
|
||||||
// tests rely on the fact that current implementation reexports protected
|
|
||||||
// constructors as public. These tests would need to be cleaned up first.
|
|
||||||
|
|
||||||
// Single argument constructor is special-cased so that it can be
|
|
||||||
// made explicit.
|
|
||||||
template <typename A>
|
|
||||||
explicit NiceMock(A&& arg) : MockClass(std::forward<A>(arg)) {
|
|
||||||
::testing::Mock::AllowUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename... An>
|
|
||||||
NiceMock(A1&& arg1, A2&& arg2, An&&... args)
|
|
||||||
: MockClass(std::forward<A1>(arg1), std::forward<A2>(arg2),
|
|
||||||
std::forward<An>(args)...) {
|
|
||||||
::testing::Mock::AllowUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// C++98 doesn't have variadic templates, so we have to define one
|
|
||||||
// for each arity.
|
|
||||||
template <typename A1>
|
|
||||||
explicit NiceMock(const A1& a1) : MockClass(a1) {
|
|
||||||
::testing::Mock::AllowUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
template <typename A1, typename A2>
|
|
||||||
NiceMock(const A1& a1, const A2& a2) : MockClass(a1, a2) {
|
|
||||||
::testing::Mock::AllowUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3>
|
|
||||||
NiceMock(const A1& a1, const A2& a2, const A3& a3) : MockClass(a1, a2, a3) {
|
|
||||||
::testing::Mock::AllowUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4>
|
|
||||||
NiceMock(const A1& a1, const A2& a2, const A3& a3,
|
|
||||||
const A4& a4) : MockClass(a1, a2, a3, a4) {
|
|
||||||
::testing::Mock::AllowUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4, typename A5>
|
|
||||||
NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
|
|
||||||
const A5& a5) : MockClass(a1, a2, a3, a4, a5) {
|
|
||||||
::testing::Mock::AllowUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
|
||||||
typename A6>
|
|
||||||
NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
|
|
||||||
const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) {
|
|
||||||
::testing::Mock::AllowUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
|
||||||
typename A6, typename A7>
|
|
||||||
NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
|
|
||||||
const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5,
|
|
||||||
a6, a7) {
|
|
||||||
::testing::Mock::AllowUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
|
||||||
typename A6, typename A7, typename A8>
|
|
||||||
NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
|
|
||||||
const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a1,
|
|
||||||
a2, a3, a4, a5, a6, a7, a8) {
|
|
||||||
::testing::Mock::AllowUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
|
||||||
typename A6, typename A7, typename A8, typename A9>
|
|
||||||
NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
|
|
||||||
const A5& a5, const A6& a6, const A7& a7, const A8& a8,
|
|
||||||
const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
|
|
||||||
::testing::Mock::AllowUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
|
||||||
typename A6, typename A7, typename A8, typename A9, typename A10>
|
|
||||||
NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
|
|
||||||
const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9,
|
|
||||||
const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
|
|
||||||
::testing::Mock::AllowUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // GTEST_LANG_CXX11
|
|
||||||
|
|
||||||
~NiceMock() {
|
|
||||||
::testing::Mock::UnregisterCallReaction(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(NiceMock);
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class MockClass>
|
|
||||||
class NaggyMock : public MockClass {
|
|
||||||
public:
|
|
||||||
NaggyMock() : MockClass() {
|
|
||||||
::testing::Mock::WarnUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
#if GTEST_LANG_CXX11
|
|
||||||
// Ideally, we would inherit base class's constructors through a using
|
|
||||||
// declaration, which would preserve their visibility. However, many existing
|
|
||||||
// tests rely on the fact that current implementation reexports protected
|
|
||||||
// constructors as public. These tests would need to be cleaned up first.
|
|
||||||
|
|
||||||
// Single argument constructor is special-cased so that it can be
|
|
||||||
// made explicit.
|
|
||||||
template <typename A>
|
|
||||||
explicit NaggyMock(A&& arg) : MockClass(std::forward<A>(arg)) {
|
|
||||||
::testing::Mock::WarnUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename... An>
|
|
||||||
NaggyMock(A1&& arg1, A2&& arg2, An&&... args)
|
|
||||||
: MockClass(std::forward<A1>(arg1), std::forward<A2>(arg2),
|
|
||||||
std::forward<An>(args)...) {
|
|
||||||
::testing::Mock::WarnUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// C++98 doesn't have variadic templates, so we have to define one
|
|
||||||
// for each arity.
|
|
||||||
template <typename A1>
|
|
||||||
explicit NaggyMock(const A1& a1) : MockClass(a1) {
|
|
||||||
::testing::Mock::WarnUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
template <typename A1, typename A2>
|
|
||||||
NaggyMock(const A1& a1, const A2& a2) : MockClass(a1, a2) {
|
|
||||||
::testing::Mock::WarnUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3>
|
|
||||||
NaggyMock(const A1& a1, const A2& a2, const A3& a3) : MockClass(a1, a2, a3) {
|
|
||||||
::testing::Mock::WarnUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4>
|
|
||||||
NaggyMock(const A1& a1, const A2& a2, const A3& a3,
|
|
||||||
const A4& a4) : MockClass(a1, a2, a3, a4) {
|
|
||||||
::testing::Mock::WarnUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4, typename A5>
|
|
||||||
NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
|
|
||||||
const A5& a5) : MockClass(a1, a2, a3, a4, a5) {
|
|
||||||
::testing::Mock::WarnUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
|
||||||
typename A6>
|
|
||||||
NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
|
|
||||||
const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) {
|
|
||||||
::testing::Mock::WarnUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
|
||||||
typename A6, typename A7>
|
|
||||||
NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
|
|
||||||
const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5,
|
|
||||||
a6, a7) {
|
|
||||||
::testing::Mock::WarnUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
|
||||||
typename A6, typename A7, typename A8>
|
|
||||||
NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
|
|
||||||
const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a1,
|
|
||||||
a2, a3, a4, a5, a6, a7, a8) {
|
|
||||||
::testing::Mock::WarnUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
|
||||||
typename A6, typename A7, typename A8, typename A9>
|
|
||||||
NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
|
|
||||||
const A5& a5, const A6& a6, const A7& a7, const A8& a8,
|
|
||||||
const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
|
|
||||||
::testing::Mock::WarnUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
|
||||||
typename A6, typename A7, typename A8, typename A9, typename A10>
|
|
||||||
NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
|
|
||||||
const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9,
|
|
||||||
const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
|
|
||||||
::testing::Mock::WarnUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // GTEST_LANG_CXX11
|
|
||||||
|
|
||||||
~NaggyMock() {
|
|
||||||
::testing::Mock::UnregisterCallReaction(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(NaggyMock);
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class MockClass>
|
|
||||||
class StrictMock : public MockClass {
|
|
||||||
public:
|
|
||||||
StrictMock() : MockClass() {
|
|
||||||
::testing::Mock::FailUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
#if GTEST_LANG_CXX11
|
|
||||||
// Ideally, we would inherit base class's constructors through a using
|
|
||||||
// declaration, which would preserve their visibility. However, many existing
|
|
||||||
// tests rely on the fact that current implementation reexports protected
|
|
||||||
// constructors as public. These tests would need to be cleaned up first.
|
|
||||||
|
|
||||||
// Single argument constructor is special-cased so that it can be
|
|
||||||
// made explicit.
|
|
||||||
template <typename A>
|
|
||||||
explicit StrictMock(A&& arg) : MockClass(std::forward<A>(arg)) {
|
|
||||||
::testing::Mock::FailUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename... An>
|
|
||||||
StrictMock(A1&& arg1, A2&& arg2, An&&... args)
|
|
||||||
: MockClass(std::forward<A1>(arg1), std::forward<A2>(arg2),
|
|
||||||
std::forward<An>(args)...) {
|
|
||||||
::testing::Mock::FailUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// C++98 doesn't have variadic templates, so we have to define one
|
|
||||||
// for each arity.
|
|
||||||
template <typename A1>
|
|
||||||
explicit StrictMock(const A1& a1) : MockClass(a1) {
|
|
||||||
::testing::Mock::FailUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
template <typename A1, typename A2>
|
|
||||||
StrictMock(const A1& a1, const A2& a2) : MockClass(a1, a2) {
|
|
||||||
::testing::Mock::FailUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3>
|
|
||||||
StrictMock(const A1& a1, const A2& a2, const A3& a3) : MockClass(a1, a2, a3) {
|
|
||||||
::testing::Mock::FailUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4>
|
|
||||||
StrictMock(const A1& a1, const A2& a2, const A3& a3,
|
|
||||||
const A4& a4) : MockClass(a1, a2, a3, a4) {
|
|
||||||
::testing::Mock::FailUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4, typename A5>
|
|
||||||
StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
|
|
||||||
const A5& a5) : MockClass(a1, a2, a3, a4, a5) {
|
|
||||||
::testing::Mock::FailUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
|
||||||
typename A6>
|
|
||||||
StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
|
|
||||||
const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) {
|
|
||||||
::testing::Mock::FailUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
|
||||||
typename A6, typename A7>
|
|
||||||
StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
|
|
||||||
const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5,
|
|
||||||
a6, a7) {
|
|
||||||
::testing::Mock::FailUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
|
||||||
typename A6, typename A7, typename A8>
|
|
||||||
StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
|
|
||||||
const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a1,
|
|
||||||
a2, a3, a4, a5, a6, a7, a8) {
|
|
||||||
::testing::Mock::FailUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
|
||||||
typename A6, typename A7, typename A8, typename A9>
|
|
||||||
StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
|
|
||||||
const A5& a5, const A6& a6, const A7& a7, const A8& a8,
|
|
||||||
const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
|
|
||||||
::testing::Mock::FailUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
|
||||||
typename A6, typename A7, typename A8, typename A9, typename A10>
|
|
||||||
StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
|
|
||||||
const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9,
|
|
||||||
const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
|
|
||||||
::testing::Mock::FailUninterestingCalls(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // GTEST_LANG_CXX11
|
|
||||||
|
|
||||||
~StrictMock() {
|
|
||||||
::testing::Mock::UnregisterCallReaction(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(StrictMock);
|
|
||||||
};
|
|
||||||
|
|
||||||
// The following specializations catch some (relatively more common)
|
|
||||||
// user errors of nesting nice and strict mocks. They do NOT catch
|
|
||||||
// all possible errors.
|
|
||||||
|
|
||||||
// These specializations are declared but not defined, as NiceMock,
|
|
||||||
// NaggyMock, and StrictMock cannot be nested.
|
|
||||||
|
|
||||||
template <typename MockClass>
|
|
||||||
class NiceMock<NiceMock<MockClass> >;
|
|
||||||
template <typename MockClass>
|
|
||||||
class NiceMock<NaggyMock<MockClass> >;
|
|
||||||
template <typename MockClass>
|
|
||||||
class NiceMock<StrictMock<MockClass> >;
|
|
||||||
|
|
||||||
template <typename MockClass>
|
|
||||||
class NaggyMock<NiceMock<MockClass> >;
|
|
||||||
template <typename MockClass>
|
|
||||||
class NaggyMock<NaggyMock<MockClass> >;
|
|
||||||
template <typename MockClass>
|
|
||||||
class NaggyMock<StrictMock<MockClass> >;
|
|
||||||
|
|
||||||
template <typename MockClass>
|
|
||||||
class StrictMock<NiceMock<MockClass> >;
|
|
||||||
template <typename MockClass>
|
|
||||||
class StrictMock<NaggyMock<MockClass> >;
|
|
||||||
template <typename MockClass>
|
|
||||||
class StrictMock<StrictMock<MockClass> >;
|
|
||||||
|
|
||||||
} // namespace testing
|
|
||||||
|
|
||||||
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
|
|
||||||
@@ -1,179 +0,0 @@
|
|||||||
$$ -*- mode: c++; -*-
|
|
||||||
$$ This is a Pump source file. Please use Pump to convert
|
|
||||||
$$ it to gmock-generated-nice-strict.h.
|
|
||||||
$$
|
|
||||||
$var n = 10 $$ The maximum arity we support.
|
|
||||||
// Copyright 2008, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
// Implements class templates NiceMock, NaggyMock, and StrictMock.
|
|
||||||
//
|
|
||||||
// Given a mock class MockFoo that is created using Google Mock,
|
|
||||||
// NiceMock<MockFoo> is a subclass of MockFoo that allows
|
|
||||||
// uninteresting calls (i.e. calls to mock methods that have no
|
|
||||||
// EXPECT_CALL specs), NaggyMock<MockFoo> is a subclass of MockFoo
|
|
||||||
// that prints a warning when an uninteresting call occurs, and
|
|
||||||
// StrictMock<MockFoo> is a subclass of MockFoo that treats all
|
|
||||||
// uninteresting calls as errors.
|
|
||||||
//
|
|
||||||
// Currently a mock is naggy by default, so MockFoo and
|
|
||||||
// NaggyMock<MockFoo> behave like the same. However, we will soon
|
|
||||||
// switch the default behavior of mocks to be nice, as that in general
|
|
||||||
// leads to more maintainable tests. When that happens, MockFoo will
|
|
||||||
// stop behaving like NaggyMock<MockFoo> and start behaving like
|
|
||||||
// NiceMock<MockFoo>.
|
|
||||||
//
|
|
||||||
// NiceMock, NaggyMock, and StrictMock "inherit" the constructors of
|
|
||||||
// their respective base class. Therefore you can write
|
|
||||||
// NiceMock<MockFoo>(5, "a") to construct a nice mock where MockFoo
|
|
||||||
// has a constructor that accepts (int, const char*), for example.
|
|
||||||
//
|
|
||||||
// A known limitation is that NiceMock<MockFoo>, NaggyMock<MockFoo>,
|
|
||||||
// and StrictMock<MockFoo> only works for mock methods defined using
|
|
||||||
// the MOCK_METHOD* family of macros DIRECTLY in the MockFoo class.
|
|
||||||
// If a mock method is defined in a base class of MockFoo, the "nice"
|
|
||||||
// or "strict" modifier may not affect it, depending on the compiler.
|
|
||||||
// In particular, nesting NiceMock, NaggyMock, and StrictMock is NOT
|
|
||||||
// supported.
|
|
||||||
|
|
||||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
|
||||||
|
|
||||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
|
|
||||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
|
|
||||||
|
|
||||||
#include "gmock/gmock-spec-builders.h"
|
|
||||||
#include "gmock/internal/gmock-port.h"
|
|
||||||
|
|
||||||
namespace testing {
|
|
||||||
|
|
||||||
$range kind 0..2
|
|
||||||
$for kind [[
|
|
||||||
|
|
||||||
$var clazz=[[$if kind==0 [[NiceMock]]
|
|
||||||
$elif kind==1 [[NaggyMock]]
|
|
||||||
$else [[StrictMock]]]]
|
|
||||||
|
|
||||||
$var method=[[$if kind==0 [[AllowUninterestingCalls]]
|
|
||||||
$elif kind==1 [[WarnUninterestingCalls]]
|
|
||||||
$else [[FailUninterestingCalls]]]]
|
|
||||||
|
|
||||||
template <class MockClass>
|
|
||||||
class $clazz : public MockClass {
|
|
||||||
public:
|
|
||||||
$clazz() : MockClass() {
|
|
||||||
::testing::Mock::$method(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
#if GTEST_LANG_CXX11
|
|
||||||
// Ideally, we would inherit base class's constructors through a using
|
|
||||||
// declaration, which would preserve their visibility. However, many existing
|
|
||||||
// tests rely on the fact that current implementation reexports protected
|
|
||||||
// constructors as public. These tests would need to be cleaned up first.
|
|
||||||
|
|
||||||
// Single argument constructor is special-cased so that it can be
|
|
||||||
// made explicit.
|
|
||||||
template <typename A>
|
|
||||||
explicit $clazz(A&& arg) : MockClass(std::forward<A>(arg)) {
|
|
||||||
::testing::Mock::$method(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename... An>
|
|
||||||
$clazz(A1&& arg1, A2&& arg2, An&&... args)
|
|
||||||
: MockClass(std::forward<A1>(arg1), std::forward<A2>(arg2),
|
|
||||||
std::forward<An>(args)...) {
|
|
||||||
::testing::Mock::$method(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// C++98 doesn't have variadic templates, so we have to define one
|
|
||||||
// for each arity.
|
|
||||||
template <typename A1>
|
|
||||||
explicit $clazz(const A1& a1) : MockClass(a1) {
|
|
||||||
::testing::Mock::$method(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
$range i 2..n
|
|
||||||
$for i [[
|
|
||||||
$range j 1..i
|
|
||||||
template <$for j, [[typename A$j]]>
|
|
||||||
$clazz($for j, [[const A$j& a$j]]) : MockClass($for j, [[a$j]]) {
|
|
||||||
::testing::Mock::$method(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
]]
|
|
||||||
#endif // GTEST_LANG_CXX11
|
|
||||||
|
|
||||||
~$clazz() {
|
|
||||||
::testing::Mock::UnregisterCallReaction(
|
|
||||||
internal::ImplicitCast_<MockClass*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
GTEST_DISALLOW_COPY_AND_ASSIGN_($clazz);
|
|
||||||
};
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
// The following specializations catch some (relatively more common)
|
|
||||||
// user errors of nesting nice and strict mocks. They do NOT catch
|
|
||||||
// all possible errors.
|
|
||||||
|
|
||||||
// These specializations are declared but not defined, as NiceMock,
|
|
||||||
// NaggyMock, and StrictMock cannot be nested.
|
|
||||||
|
|
||||||
template <typename MockClass>
|
|
||||||
class NiceMock<NiceMock<MockClass> >;
|
|
||||||
template <typename MockClass>
|
|
||||||
class NiceMock<NaggyMock<MockClass> >;
|
|
||||||
template <typename MockClass>
|
|
||||||
class NiceMock<StrictMock<MockClass> >;
|
|
||||||
|
|
||||||
template <typename MockClass>
|
|
||||||
class NaggyMock<NiceMock<MockClass> >;
|
|
||||||
template <typename MockClass>
|
|
||||||
class NaggyMock<NaggyMock<MockClass> >;
|
|
||||||
template <typename MockClass>
|
|
||||||
class NaggyMock<StrictMock<MockClass> >;
|
|
||||||
|
|
||||||
template <typename MockClass>
|
|
||||||
class StrictMock<NiceMock<MockClass> >;
|
|
||||||
template <typename MockClass>
|
|
||||||
class StrictMock<NaggyMock<MockClass> >;
|
|
||||||
template <typename MockClass>
|
|
||||||
class StrictMock<StrictMock<MockClass> >;
|
|
||||||
|
|
||||||
} // namespace testing
|
|
||||||
|
|
||||||
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,247 +0,0 @@
|
|||||||
// Copyright 2007, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
// Google Mock - a framework for writing C++ mock classes.
|
|
||||||
//
|
|
||||||
// This file implements some actions that depend on gmock-generated-actions.h.
|
|
||||||
|
|
||||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
|
||||||
|
|
||||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
|
|
||||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
#include "gmock/gmock-generated-actions.h"
|
|
||||||
|
|
||||||
namespace testing {
|
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
// Implements the Invoke(f) action. The template argument
|
|
||||||
// FunctionImpl is the implementation type of f, which can be either a
|
|
||||||
// function pointer or a functor. Invoke(f) can be used as an
|
|
||||||
// Action<F> as long as f's type is compatible with F (i.e. f can be
|
|
||||||
// assigned to a tr1::function<F>).
|
|
||||||
template <typename FunctionImpl>
|
|
||||||
class InvokeAction {
|
|
||||||
public:
|
|
||||||
// The c'tor makes a copy of function_impl (either a function
|
|
||||||
// pointer or a functor).
|
|
||||||
explicit InvokeAction(FunctionImpl function_impl)
|
|
||||||
: function_impl_(function_impl) {}
|
|
||||||
|
|
||||||
template <typename Result, typename ArgumentTuple>
|
|
||||||
Result Perform(const ArgumentTuple& args) {
|
|
||||||
return InvokeHelper<Result, ArgumentTuple>::Invoke(function_impl_, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
FunctionImpl function_impl_;
|
|
||||||
|
|
||||||
GTEST_DISALLOW_ASSIGN_(InvokeAction);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Implements the Invoke(object_ptr, &Class::Method) action.
|
|
||||||
template <class Class, typename MethodPtr>
|
|
||||||
class InvokeMethodAction {
|
|
||||||
public:
|
|
||||||
InvokeMethodAction(Class* obj_ptr, MethodPtr method_ptr)
|
|
||||||
: method_ptr_(method_ptr), obj_ptr_(obj_ptr) {}
|
|
||||||
|
|
||||||
template <typename Result, typename ArgumentTuple>
|
|
||||||
Result Perform(const ArgumentTuple& args) const {
|
|
||||||
return InvokeHelper<Result, ArgumentTuple>::InvokeMethod(
|
|
||||||
obj_ptr_, method_ptr_, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
// The order of these members matters. Reversing the order can trigger
|
|
||||||
// warning C4121 in MSVC (see
|
|
||||||
// http://computer-programming-forum.com/7-vc.net/6fbc30265f860ad1.htm ).
|
|
||||||
const MethodPtr method_ptr_;
|
|
||||||
Class* const obj_ptr_;
|
|
||||||
|
|
||||||
GTEST_DISALLOW_ASSIGN_(InvokeMethodAction);
|
|
||||||
};
|
|
||||||
|
|
||||||
// An internal replacement for std::copy which mimics its behavior. This is
|
|
||||||
// necessary because Visual Studio deprecates ::std::copy, issuing warning 4996.
|
|
||||||
// However Visual Studio 2010 and later do not honor #pragmas which disable that
|
|
||||||
// warning.
|
|
||||||
template<typename InputIterator, typename OutputIterator>
|
|
||||||
inline OutputIterator CopyElements(InputIterator first,
|
|
||||||
InputIterator last,
|
|
||||||
OutputIterator output) {
|
|
||||||
for (; first != last; ++first, ++output) {
|
|
||||||
*output = *first;
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
|
|
||||||
// Various overloads for Invoke().
|
|
||||||
|
|
||||||
// Creates an action that invokes 'function_impl' with the mock
|
|
||||||
// function's arguments.
|
|
||||||
template <typename FunctionImpl>
|
|
||||||
PolymorphicAction<internal::InvokeAction<FunctionImpl> > Invoke(
|
|
||||||
FunctionImpl function_impl) {
|
|
||||||
return MakePolymorphicAction(
|
|
||||||
internal::InvokeAction<FunctionImpl>(function_impl));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Creates an action that invokes the given method on the given object
|
|
||||||
// with the mock function's arguments.
|
|
||||||
template <class Class, typename MethodPtr>
|
|
||||||
PolymorphicAction<internal::InvokeMethodAction<Class, MethodPtr> > Invoke(
|
|
||||||
Class* obj_ptr, MethodPtr method_ptr) {
|
|
||||||
return MakePolymorphicAction(
|
|
||||||
internal::InvokeMethodAction<Class, MethodPtr>(obj_ptr, method_ptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
// WithoutArgs(inner_action) can be used in a mock function with a
|
|
||||||
// non-empty argument list to perform inner_action, which takes no
|
|
||||||
// argument. In other words, it adapts an action accepting no
|
|
||||||
// argument to one that accepts (and ignores) arguments.
|
|
||||||
template <typename InnerAction>
|
|
||||||
inline internal::WithArgsAction<InnerAction>
|
|
||||||
WithoutArgs(const InnerAction& action) {
|
|
||||||
return internal::WithArgsAction<InnerAction>(action);
|
|
||||||
}
|
|
||||||
|
|
||||||
// WithArg<k>(an_action) creates an action that passes the k-th
|
|
||||||
// (0-based) argument of the mock function to an_action and performs
|
|
||||||
// it. It adapts an action accepting one argument to one that accepts
|
|
||||||
// multiple arguments. For convenience, we also provide
|
|
||||||
// WithArgs<k>(an_action) (defined below) as a synonym.
|
|
||||||
template <int k, typename InnerAction>
|
|
||||||
inline internal::WithArgsAction<InnerAction, k>
|
|
||||||
WithArg(const InnerAction& action) {
|
|
||||||
return internal::WithArgsAction<InnerAction, k>(action);
|
|
||||||
}
|
|
||||||
|
|
||||||
// The ACTION*() macros trigger warning C4100 (unreferenced formal
|
|
||||||
// parameter) in MSVC with -W4. Unfortunately they cannot be fixed in
|
|
||||||
// the macro definition, as the warnings are generated when the macro
|
|
||||||
// is expanded and macro expansion cannot contain #pragma. Therefore
|
|
||||||
// we suppress them here.
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
# pragma warning(push)
|
|
||||||
# pragma warning(disable:4100)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Action ReturnArg<k>() returns the k-th argument of the mock function.
|
|
||||||
ACTION_TEMPLATE(ReturnArg,
|
|
||||||
HAS_1_TEMPLATE_PARAMS(int, k),
|
|
||||||
AND_0_VALUE_PARAMS()) {
|
|
||||||
return ::testing::get<k>(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Action SaveArg<k>(pointer) saves the k-th (0-based) argument of the
|
|
||||||
// mock function to *pointer.
|
|
||||||
ACTION_TEMPLATE(SaveArg,
|
|
||||||
HAS_1_TEMPLATE_PARAMS(int, k),
|
|
||||||
AND_1_VALUE_PARAMS(pointer)) {
|
|
||||||
*pointer = ::testing::get<k>(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Action SaveArgPointee<k>(pointer) saves the value pointed to
|
|
||||||
// by the k-th (0-based) argument of the mock function to *pointer.
|
|
||||||
ACTION_TEMPLATE(SaveArgPointee,
|
|
||||||
HAS_1_TEMPLATE_PARAMS(int, k),
|
|
||||||
AND_1_VALUE_PARAMS(pointer)) {
|
|
||||||
*pointer = *::testing::get<k>(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Action SetArgReferee<k>(value) assigns 'value' to the variable
|
|
||||||
// referenced by the k-th (0-based) argument of the mock function.
|
|
||||||
ACTION_TEMPLATE(SetArgReferee,
|
|
||||||
HAS_1_TEMPLATE_PARAMS(int, k),
|
|
||||||
AND_1_VALUE_PARAMS(value)) {
|
|
||||||
typedef typename ::testing::tuple_element<k, args_type>::type argk_type;
|
|
||||||
// Ensures that argument #k is a reference. If you get a compiler
|
|
||||||
// error on the next line, you are using SetArgReferee<k>(value) in
|
|
||||||
// a mock function whose k-th (0-based) argument is not a reference.
|
|
||||||
GTEST_COMPILE_ASSERT_(internal::is_reference<argk_type>::value,
|
|
||||||
SetArgReferee_must_be_used_with_a_reference_argument);
|
|
||||||
::testing::get<k>(args) = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Action SetArrayArgument<k>(first, last) copies the elements in
|
|
||||||
// source range [first, last) to the array pointed to by the k-th
|
|
||||||
// (0-based) argument, which can be either a pointer or an
|
|
||||||
// iterator. The action does not take ownership of the elements in the
|
|
||||||
// source range.
|
|
||||||
ACTION_TEMPLATE(SetArrayArgument,
|
|
||||||
HAS_1_TEMPLATE_PARAMS(int, k),
|
|
||||||
AND_2_VALUE_PARAMS(first, last)) {
|
|
||||||
// Visual Studio deprecates ::std::copy, so we use our own copy in that case.
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
internal::CopyElements(first, last, ::testing::get<k>(args));
|
|
||||||
#else
|
|
||||||
::std::copy(first, last, ::testing::get<k>(args));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// Action DeleteArg<k>() deletes the k-th (0-based) argument of the mock
|
|
||||||
// function.
|
|
||||||
ACTION_TEMPLATE(DeleteArg,
|
|
||||||
HAS_1_TEMPLATE_PARAMS(int, k),
|
|
||||||
AND_0_VALUE_PARAMS()) {
|
|
||||||
delete ::testing::get<k>(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
// This action returns the value pointed to by 'pointer'.
|
|
||||||
ACTION_P(ReturnPointee, pointer) { return *pointer; }
|
|
||||||
|
|
||||||
// Action Throw(exception) can be used in a mock function of any type
|
|
||||||
// to throw the given exception. Any copyable value can be thrown.
|
|
||||||
#if GTEST_HAS_EXCEPTIONS
|
|
||||||
|
|
||||||
// Suppresses the 'unreachable code' warning that VC generates in opt modes.
|
|
||||||
# ifdef _MSC_VER
|
|
||||||
# pragma warning(push) // Saves the current warning state.
|
|
||||||
# pragma warning(disable:4702) // Temporarily disables warning 4702.
|
|
||||||
# endif
|
|
||||||
ACTION_P(Throw, exception) { throw exception; }
|
|
||||||
# ifdef _MSC_VER
|
|
||||||
# pragma warning(pop) // Restores the warning state.
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#endif // GTEST_HAS_EXCEPTIONS
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
# pragma warning(pop)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace testing
|
|
||||||
|
|
||||||
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
// Copyright 2013, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
// Google Mock - a framework for writing C++ mock classes.
|
|
||||||
//
|
|
||||||
// This file implements some matchers that depend on gmock-generated-matchers.h.
|
|
||||||
//
|
|
||||||
// Note that tests are implemented in gmock-matchers_test.cc rather than
|
|
||||||
// gmock-more-matchers-test.cc.
|
|
||||||
|
|
||||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
|
||||||
|
|
||||||
#ifndef GMOCK_INCLUDE_GMOCK_MORE_MATCHERS_H_
|
|
||||||
#define GMOCK_INCLUDE_GMOCK_MORE_MATCHERS_H_
|
|
||||||
|
|
||||||
#include "gmock/gmock-generated-matchers.h"
|
|
||||||
|
|
||||||
namespace testing {
|
|
||||||
|
|
||||||
// Silence C4100 (unreferenced formal
|
|
||||||
// parameter) for MSVC
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
# pragma warning(push)
|
|
||||||
# pragma warning(disable:4100)
|
|
||||||
#if (_MSC_VER == 1900)
|
|
||||||
// and silence C4800 (C4800: 'int *const ': forcing value
|
|
||||||
// to bool 'true' or 'false') for MSVC 14
|
|
||||||
# pragma warning(disable:4800)
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Defines a matcher that matches an empty container. The container must
|
|
||||||
// support both size() and empty(), which all STL-like containers provide.
|
|
||||||
MATCHER(IsEmpty, negation ? "isn't empty" : "is empty") {
|
|
||||||
if (arg.empty()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
*result_listener << "whose size is " << arg.size();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define a matcher that matches a value that evaluates in boolean
|
|
||||||
// context to true. Useful for types that define "explicit operator
|
|
||||||
// bool" operators and so can't be compared for equality with true
|
|
||||||
// and false.
|
|
||||||
MATCHER(IsTrue, negation ? "is false" : "is true") {
|
|
||||||
return static_cast<bool>(arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define a matcher that matches a value that evaluates in boolean
|
|
||||||
// context to false. Useful for types that define "explicit operator
|
|
||||||
// bool" operators and so can't be compared for equality with true
|
|
||||||
// and false.
|
|
||||||
MATCHER(IsFalse, negation ? "is true" : "is false") {
|
|
||||||
return !static_cast<bool>(arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
# pragma warning(pop)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace testing
|
|
||||||
|
|
||||||
#endif // GMOCK_INCLUDE_GMOCK_MORE_MATCHERS_H_
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,96 +0,0 @@
|
|||||||
// Copyright 2007, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
// Google Mock - a framework for writing C++ mock classes.
|
|
||||||
//
|
|
||||||
// This is the main header file a user should include.
|
|
||||||
|
|
||||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
|
||||||
|
|
||||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_H_
|
|
||||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_H_
|
|
||||||
|
|
||||||
// This file implements the following syntax:
|
|
||||||
//
|
|
||||||
// ON_CALL(mock_object.Method(...))
|
|
||||||
// .With(...) ?
|
|
||||||
// .WillByDefault(...);
|
|
||||||
//
|
|
||||||
// where With() is optional and WillByDefault() must appear exactly
|
|
||||||
// once.
|
|
||||||
//
|
|
||||||
// EXPECT_CALL(mock_object.Method(...))
|
|
||||||
// .With(...) ?
|
|
||||||
// .Times(...) ?
|
|
||||||
// .InSequence(...) *
|
|
||||||
// .WillOnce(...) *
|
|
||||||
// .WillRepeatedly(...) ?
|
|
||||||
// .RetiresOnSaturation() ? ;
|
|
||||||
//
|
|
||||||
// where all clauses are optional and WillOnce() can be repeated.
|
|
||||||
|
|
||||||
#include "gmock/gmock-actions.h"
|
|
||||||
#include "gmock/gmock-cardinalities.h"
|
|
||||||
#include "gmock/gmock-generated-actions.h"
|
|
||||||
#include "gmock/gmock-generated-function-mockers.h"
|
|
||||||
#include "gmock/gmock-generated-matchers.h"
|
|
||||||
#include "gmock/gmock-generated-nice-strict.h"
|
|
||||||
#include "gmock/gmock-matchers.h"
|
|
||||||
#include "gmock/gmock-more-actions.h"
|
|
||||||
#include "gmock/gmock-more-matchers.h"
|
|
||||||
#include "gmock/internal/gmock-internal-utils.h"
|
|
||||||
|
|
||||||
namespace testing {
|
|
||||||
|
|
||||||
// Declares Google Mock flags that we want a user to use programmatically.
|
|
||||||
GMOCK_DECLARE_bool_(catch_leaked_mocks);
|
|
||||||
GMOCK_DECLARE_string_(verbose);
|
|
||||||
GMOCK_DECLARE_int32_(default_mock_behavior);
|
|
||||||
|
|
||||||
// Initializes Google Mock. This must be called before running the
|
|
||||||
// tests. In particular, it parses the command line for the flags
|
|
||||||
// that Google Mock recognizes. Whenever a Google Mock flag is seen,
|
|
||||||
// it is removed from argv, and *argc is decremented.
|
|
||||||
//
|
|
||||||
// No value is returned. Instead, the Google Mock flag variables are
|
|
||||||
// updated.
|
|
||||||
//
|
|
||||||
// Since Google Test is needed for Google Mock to work, this function
|
|
||||||
// also initializes Google Test and parses its flags, if that hasn't
|
|
||||||
// been done.
|
|
||||||
GTEST_API_ void InitGoogleMock(int* argc, char** argv);
|
|
||||||
|
|
||||||
// This overloaded version can be used in Windows programs compiled in
|
|
||||||
// UNICODE mode.
|
|
||||||
GTEST_API_ void InitGoogleMock(int* argc, wchar_t** argv);
|
|
||||||
|
|
||||||
} // namespace testing
|
|
||||||
|
|
||||||
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_H_
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
# Customization Points
|
|
||||||
|
|
||||||
The custom directory is an injection point for custom user configurations.
|
|
||||||
|
|
||||||
## Header `gmock-port.h`
|
|
||||||
|
|
||||||
The following macros can be defined:
|
|
||||||
|
|
||||||
### Flag related macros:
|
|
||||||
|
|
||||||
* `GMOCK_DECLARE_bool_(name)`
|
|
||||||
* `GMOCK_DECLARE_int32_(name)`
|
|
||||||
* `GMOCK_DECLARE_string_(name)`
|
|
||||||
* `GMOCK_DEFINE_bool_(name, default_val, doc)`
|
|
||||||
* `GMOCK_DEFINE_int32_(name, default_val, doc)`
|
|
||||||
* `GMOCK_DEFINE_string_(name, default_val, doc)`
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
// This file was GENERATED by command:
|
|
||||||
// pump.py gmock-generated-actions.h.pump
|
|
||||||
// DO NOT EDIT BY HAND!!!
|
|
||||||
|
|
||||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
|
||||||
|
|
||||||
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_
|
|
||||||
#define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_
|
|
||||||
|
|
||||||
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
$$ -*- mode: c++; -*-
|
|
||||||
$$ This is a Pump source file. Please use Pump to convert
|
|
||||||
$$ it to callback-actions.h.
|
|
||||||
$$
|
|
||||||
$var max_callback_arity = 5
|
|
||||||
$$}} This meta comment fixes auto-indentation in editors.
|
|
||||||
|
|
||||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
|
||||||
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_
|
|
||||||
#define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_
|
|
||||||
|
|
||||||
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
// Copyright 2015, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
//
|
|
||||||
// Injection point for custom user configurations. See README for details
|
|
||||||
//
|
|
||||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
|
||||||
|
|
||||||
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_
|
|
||||||
#define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_
|
|
||||||
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
// Copyright 2015, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
//
|
|
||||||
// Injection point for custom user configurations. See README for details
|
|
||||||
//
|
|
||||||
// ** Custom implementation starts here **
|
|
||||||
|
|
||||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
|
||||||
|
|
||||||
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_
|
|
||||||
#define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_
|
|
||||||
|
|
||||||
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_
|
|
||||||
@@ -1,287 +0,0 @@
|
|||||||
// This file was GENERATED by command:
|
|
||||||
// pump.py gmock-generated-internal-utils.h.pump
|
|
||||||
// DO NOT EDIT BY HAND!!!
|
|
||||||
|
|
||||||
// Copyright 2007, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
// Google Mock - a framework for writing C++ mock classes.
|
|
||||||
//
|
|
||||||
// This file contains template meta-programming utility classes needed
|
|
||||||
// for implementing Google Mock.
|
|
||||||
|
|
||||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
|
||||||
|
|
||||||
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
|
|
||||||
#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
|
|
||||||
|
|
||||||
#include "gmock/internal/gmock-port.h"
|
|
||||||
|
|
||||||
namespace testing {
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
class Matcher;
|
|
||||||
|
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
// An IgnoredValue object can be implicitly constructed from ANY value.
|
|
||||||
// This is used in implementing the IgnoreResult(a) action.
|
|
||||||
class IgnoredValue {
|
|
||||||
public:
|
|
||||||
// This constructor template allows any value to be implicitly
|
|
||||||
// converted to IgnoredValue. The object has no data member and
|
|
||||||
// doesn't try to remember anything about the argument. We
|
|
||||||
// deliberately omit the 'explicit' keyword in order to allow the
|
|
||||||
// conversion to be implicit.
|
|
||||||
template <typename T>
|
|
||||||
IgnoredValue(const T& /* ignored */) {} // NOLINT(runtime/explicit)
|
|
||||||
};
|
|
||||||
|
|
||||||
// MatcherTuple<T>::type is a tuple type where each field is a Matcher
|
|
||||||
// for the corresponding field in tuple type T.
|
|
||||||
template <typename Tuple>
|
|
||||||
struct MatcherTuple;
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct MatcherTuple< ::testing::tuple<> > {
|
|
||||||
typedef ::testing::tuple< > type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename A1>
|
|
||||||
struct MatcherTuple< ::testing::tuple<A1> > {
|
|
||||||
typedef ::testing::tuple<Matcher<A1> > type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename A1, typename A2>
|
|
||||||
struct MatcherTuple< ::testing::tuple<A1, A2> > {
|
|
||||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2> > type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3>
|
|
||||||
struct MatcherTuple< ::testing::tuple<A1, A2, A3> > {
|
|
||||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3> > type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4>
|
|
||||||
struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4> > {
|
|
||||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4> >
|
|
||||||
type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4, typename A5>
|
|
||||||
struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5> > {
|
|
||||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
|
|
||||||
Matcher<A5> >
|
|
||||||
type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
|
||||||
typename A6>
|
|
||||||
struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6> > {
|
|
||||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
|
|
||||||
Matcher<A5>, Matcher<A6> >
|
|
||||||
type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
|
||||||
typename A6, typename A7>
|
|
||||||
struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6, A7> > {
|
|
||||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
|
|
||||||
Matcher<A5>, Matcher<A6>, Matcher<A7> >
|
|
||||||
type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
|
||||||
typename A6, typename A7, typename A8>
|
|
||||||
struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {
|
|
||||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
|
|
||||||
Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8> >
|
|
||||||
type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
|
||||||
typename A6, typename A7, typename A8, typename A9>
|
|
||||||
struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > {
|
|
||||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
|
|
||||||
Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>,
|
|
||||||
Matcher<A9> >
|
|
||||||
type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
|
||||||
typename A6, typename A7, typename A8, typename A9, typename A10>
|
|
||||||
struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
|
|
||||||
A10> > {
|
|
||||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
|
|
||||||
Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>,
|
|
||||||
Matcher<A9>, Matcher<A10> >
|
|
||||||
type;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Template struct Function<F>, where F must be a function type, contains
|
|
||||||
// the following typedefs:
|
|
||||||
//
|
|
||||||
// Result: the function's return type.
|
|
||||||
// ArgumentN: the type of the N-th argument, where N starts with 1.
|
|
||||||
// ArgumentTuple: the tuple type consisting of all parameters of F.
|
|
||||||
// ArgumentMatcherTuple: the tuple type consisting of Matchers for all
|
|
||||||
// parameters of F.
|
|
||||||
// MakeResultVoid: the function type obtained by substituting void
|
|
||||||
// for the return type of F.
|
|
||||||
// MakeResultIgnoredValue:
|
|
||||||
// the function type obtained by substituting Something
|
|
||||||
// for the return type of F.
|
|
||||||
template <typename F>
|
|
||||||
struct Function;
|
|
||||||
|
|
||||||
template <typename R>
|
|
||||||
struct Function<R()> {
|
|
||||||
typedef R Result;
|
|
||||||
typedef ::testing::tuple<> ArgumentTuple;
|
|
||||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
|
||||||
typedef void MakeResultVoid();
|
|
||||||
typedef IgnoredValue MakeResultIgnoredValue();
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename R, typename A1>
|
|
||||||
struct Function<R(A1)>
|
|
||||||
: Function<R()> {
|
|
||||||
typedef A1 Argument1;
|
|
||||||
typedef ::testing::tuple<A1> ArgumentTuple;
|
|
||||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
|
||||||
typedef void MakeResultVoid(A1);
|
|
||||||
typedef IgnoredValue MakeResultIgnoredValue(A1);
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename R, typename A1, typename A2>
|
|
||||||
struct Function<R(A1, A2)>
|
|
||||||
: Function<R(A1)> {
|
|
||||||
typedef A2 Argument2;
|
|
||||||
typedef ::testing::tuple<A1, A2> ArgumentTuple;
|
|
||||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
|
||||||
typedef void MakeResultVoid(A1, A2);
|
|
||||||
typedef IgnoredValue MakeResultIgnoredValue(A1, A2);
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename R, typename A1, typename A2, typename A3>
|
|
||||||
struct Function<R(A1, A2, A3)>
|
|
||||||
: Function<R(A1, A2)> {
|
|
||||||
typedef A3 Argument3;
|
|
||||||
typedef ::testing::tuple<A1, A2, A3> ArgumentTuple;
|
|
||||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
|
||||||
typedef void MakeResultVoid(A1, A2, A3);
|
|
||||||
typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3);
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename R, typename A1, typename A2, typename A3, typename A4>
|
|
||||||
struct Function<R(A1, A2, A3, A4)>
|
|
||||||
: Function<R(A1, A2, A3)> {
|
|
||||||
typedef A4 Argument4;
|
|
||||||
typedef ::testing::tuple<A1, A2, A3, A4> ArgumentTuple;
|
|
||||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
|
||||||
typedef void MakeResultVoid(A1, A2, A3, A4);
|
|
||||||
typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4);
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
|
||||||
typename A5>
|
|
||||||
struct Function<R(A1, A2, A3, A4, A5)>
|
|
||||||
: Function<R(A1, A2, A3, A4)> {
|
|
||||||
typedef A5 Argument5;
|
|
||||||
typedef ::testing::tuple<A1, A2, A3, A4, A5> ArgumentTuple;
|
|
||||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
|
||||||
typedef void MakeResultVoid(A1, A2, A3, A4, A5);
|
|
||||||
typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5);
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
|
||||||
typename A5, typename A6>
|
|
||||||
struct Function<R(A1, A2, A3, A4, A5, A6)>
|
|
||||||
: Function<R(A1, A2, A3, A4, A5)> {
|
|
||||||
typedef A6 Argument6;
|
|
||||||
typedef ::testing::tuple<A1, A2, A3, A4, A5, A6> ArgumentTuple;
|
|
||||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
|
||||||
typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6);
|
|
||||||
typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6);
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
|
||||||
typename A5, typename A6, typename A7>
|
|
||||||
struct Function<R(A1, A2, A3, A4, A5, A6, A7)>
|
|
||||||
: Function<R(A1, A2, A3, A4, A5, A6)> {
|
|
||||||
typedef A7 Argument7;
|
|
||||||
typedef ::testing::tuple<A1, A2, A3, A4, A5, A6, A7> ArgumentTuple;
|
|
||||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
|
||||||
typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7);
|
|
||||||
typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7);
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
|
||||||
typename A5, typename A6, typename A7, typename A8>
|
|
||||||
struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8)>
|
|
||||||
: Function<R(A1, A2, A3, A4, A5, A6, A7)> {
|
|
||||||
typedef A8 Argument8;
|
|
||||||
typedef ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8> ArgumentTuple;
|
|
||||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
|
||||||
typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8);
|
|
||||||
typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8);
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
|
||||||
typename A5, typename A6, typename A7, typename A8, typename A9>
|
|
||||||
struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)>
|
|
||||||
: Function<R(A1, A2, A3, A4, A5, A6, A7, A8)> {
|
|
||||||
typedef A9 Argument9;
|
|
||||||
typedef ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> ArgumentTuple;
|
|
||||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
|
||||||
typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9);
|
|
||||||
typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8,
|
|
||||||
A9);
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
|
||||||
typename A5, typename A6, typename A7, typename A8, typename A9,
|
|
||||||
typename A10>
|
|
||||||
struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
|
|
||||||
: Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
|
|
||||||
typedef A10 Argument10;
|
|
||||||
typedef ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
|
|
||||||
A10> ArgumentTuple;
|
|
||||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
|
||||||
typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
|
|
||||||
typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8,
|
|
||||||
A9, A10);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
|
|
||||||
} // namespace testing
|
|
||||||
|
|
||||||
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
|
|
||||||
@@ -1,137 +0,0 @@
|
|||||||
$$ -*- mode: c++; -*-
|
|
||||||
$$ This is a Pump source file. Please use Pump to convert it to
|
|
||||||
$$ gmock-generated-function-mockers.h.
|
|
||||||
$$
|
|
||||||
$var n = 10 $$ The maximum arity we support.
|
|
||||||
// Copyright 2007, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
// Google Mock - a framework for writing C++ mock classes.
|
|
||||||
//
|
|
||||||
// This file contains template meta-programming utility classes needed
|
|
||||||
// for implementing Google Mock.
|
|
||||||
|
|
||||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
|
||||||
|
|
||||||
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
|
|
||||||
#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
|
|
||||||
|
|
||||||
#include "gmock/internal/gmock-port.h"
|
|
||||||
|
|
||||||
namespace testing {
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
class Matcher;
|
|
||||||
|
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
// An IgnoredValue object can be implicitly constructed from ANY value.
|
|
||||||
// This is used in implementing the IgnoreResult(a) action.
|
|
||||||
class IgnoredValue {
|
|
||||||
public:
|
|
||||||
// This constructor template allows any value to be implicitly
|
|
||||||
// converted to IgnoredValue. The object has no data member and
|
|
||||||
// doesn't try to remember anything about the argument. We
|
|
||||||
// deliberately omit the 'explicit' keyword in order to allow the
|
|
||||||
// conversion to be implicit.
|
|
||||||
template <typename T>
|
|
||||||
IgnoredValue(const T& /* ignored */) {} // NOLINT(runtime/explicit)
|
|
||||||
};
|
|
||||||
|
|
||||||
// MatcherTuple<T>::type is a tuple type where each field is a Matcher
|
|
||||||
// for the corresponding field in tuple type T.
|
|
||||||
template <typename Tuple>
|
|
||||||
struct MatcherTuple;
|
|
||||||
|
|
||||||
|
|
||||||
$range i 0..n
|
|
||||||
$for i [[
|
|
||||||
$range j 1..i
|
|
||||||
$var typename_As = [[$for j, [[typename A$j]]]]
|
|
||||||
$var As = [[$for j, [[A$j]]]]
|
|
||||||
$var matcher_As = [[$for j, [[Matcher<A$j>]]]]
|
|
||||||
template <$typename_As>
|
|
||||||
struct MatcherTuple< ::testing::tuple<$As> > {
|
|
||||||
typedef ::testing::tuple<$matcher_As > type;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
]]
|
|
||||||
// Template struct Function<F>, where F must be a function type, contains
|
|
||||||
// the following typedefs:
|
|
||||||
//
|
|
||||||
// Result: the function's return type.
|
|
||||||
// ArgumentN: the type of the N-th argument, where N starts with 1.
|
|
||||||
// ArgumentTuple: the tuple type consisting of all parameters of F.
|
|
||||||
// ArgumentMatcherTuple: the tuple type consisting of Matchers for all
|
|
||||||
// parameters of F.
|
|
||||||
// MakeResultVoid: the function type obtained by substituting void
|
|
||||||
// for the return type of F.
|
|
||||||
// MakeResultIgnoredValue:
|
|
||||||
// the function type obtained by substituting Something
|
|
||||||
// for the return type of F.
|
|
||||||
template <typename F>
|
|
||||||
struct Function;
|
|
||||||
|
|
||||||
template <typename R>
|
|
||||||
struct Function<R()> {
|
|
||||||
typedef R Result;
|
|
||||||
typedef ::testing::tuple<> ArgumentTuple;
|
|
||||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
|
||||||
typedef void MakeResultVoid();
|
|
||||||
typedef IgnoredValue MakeResultIgnoredValue();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
$range i 1..n
|
|
||||||
$for i [[
|
|
||||||
$range j 1..i
|
|
||||||
$var typename_As = [[$for j [[, typename A$j]]]]
|
|
||||||
$var As = [[$for j, [[A$j]]]]
|
|
||||||
$var matcher_As = [[$for j, [[Matcher<A$j>]]]]
|
|
||||||
$range k 1..i-1
|
|
||||||
$var prev_As = [[$for k, [[A$k]]]]
|
|
||||||
template <typename R$typename_As>
|
|
||||||
struct Function<R($As)>
|
|
||||||
: Function<R($prev_As)> {
|
|
||||||
typedef A$i Argument$i;
|
|
||||||
typedef ::testing::tuple<$As> ArgumentTuple;
|
|
||||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
|
||||||
typedef void MakeResultVoid($As);
|
|
||||||
typedef IgnoredValue MakeResultIgnoredValue($As);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
]]
|
|
||||||
} // namespace internal
|
|
||||||
|
|
||||||
} // namespace testing
|
|
||||||
|
|
||||||
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
|
|
||||||
@@ -1,575 +0,0 @@
|
|||||||
// Copyright 2007, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
// Google Mock - a framework for writing C++ mock classes.
|
|
||||||
//
|
|
||||||
// This file defines some utilities useful for implementing Google
|
|
||||||
// Mock. They are subject to change without notice, so please DO NOT
|
|
||||||
// USE THEM IN USER CODE.
|
|
||||||
|
|
||||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
|
||||||
|
|
||||||
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
|
|
||||||
#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <ostream> // NOLINT
|
|
||||||
#include <string>
|
|
||||||
#include "gmock/internal/gmock-generated-internal-utils.h"
|
|
||||||
#include "gmock/internal/gmock-port.h"
|
|
||||||
#include "gtest/gtest.h"
|
|
||||||
|
|
||||||
namespace testing {
|
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
// Silence MSVC C4100 (unreferenced formal parameter) and
|
|
||||||
// C4805('==': unsafe mix of type 'const int' and type 'const bool')
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
# pragma warning(push)
|
|
||||||
# pragma warning(disable:4100)
|
|
||||||
# pragma warning(disable:4805)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Joins a vector of strings as if they are fields of a tuple; returns
|
|
||||||
// the joined string.
|
|
||||||
GTEST_API_ std::string JoinAsTuple(const Strings& fields);
|
|
||||||
|
|
||||||
// Converts an identifier name to a space-separated list of lower-case
|
|
||||||
// words. Each maximum substring of the form [A-Za-z][a-z]*|\d+ is
|
|
||||||
// treated as one word. For example, both "FooBar123" and
|
|
||||||
// "foo_bar_123" are converted to "foo bar 123".
|
|
||||||
GTEST_API_ std::string ConvertIdentifierNameToWords(const char* id_name);
|
|
||||||
|
|
||||||
// PointeeOf<Pointer>::type is the type of a value pointed to by a
|
|
||||||
// Pointer, which can be either a smart pointer or a raw pointer. The
|
|
||||||
// following default implementation is for the case where Pointer is a
|
|
||||||
// smart pointer.
|
|
||||||
template <typename Pointer>
|
|
||||||
struct PointeeOf {
|
|
||||||
// Smart pointer classes define type element_type as the type of
|
|
||||||
// their pointees.
|
|
||||||
typedef typename Pointer::element_type type;
|
|
||||||
};
|
|
||||||
// This specialization is for the raw pointer case.
|
|
||||||
template <typename T>
|
|
||||||
struct PointeeOf<T*> { typedef T type; }; // NOLINT
|
|
||||||
|
|
||||||
// GetRawPointer(p) returns the raw pointer underlying p when p is a
|
|
||||||
// smart pointer, or returns p itself when p is already a raw pointer.
|
|
||||||
// The following default implementation is for the smart pointer case.
|
|
||||||
template <typename Pointer>
|
|
||||||
inline const typename Pointer::element_type* GetRawPointer(const Pointer& p) {
|
|
||||||
return p.get();
|
|
||||||
}
|
|
||||||
// This overloaded version is for the raw pointer case.
|
|
||||||
template <typename Element>
|
|
||||||
inline Element* GetRawPointer(Element* p) { return p; }
|
|
||||||
|
|
||||||
// This comparator allows linked_ptr to be stored in sets.
|
|
||||||
template <typename T>
|
|
||||||
struct LinkedPtrLessThan {
|
|
||||||
bool operator()(const ::testing::internal::linked_ptr<T>& lhs,
|
|
||||||
const ::testing::internal::linked_ptr<T>& rhs) const {
|
|
||||||
return lhs.get() < rhs.get();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Symbian compilation can be done with wchar_t being either a native
|
|
||||||
// type or a typedef. Using Google Mock with OpenC without wchar_t
|
|
||||||
// should require the definition of _STLP_NO_WCHAR_T.
|
|
||||||
//
|
|
||||||
// MSVC treats wchar_t as a native type usually, but treats it as the
|
|
||||||
// same as unsigned short when the compiler option /Zc:wchar_t- is
|
|
||||||
// specified. It defines _NATIVE_WCHAR_T_DEFINED symbol when wchar_t
|
|
||||||
// is a native type.
|
|
||||||
#if (GTEST_OS_SYMBIAN && defined(_STLP_NO_WCHAR_T)) || \
|
|
||||||
(defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED))
|
|
||||||
// wchar_t is a typedef.
|
|
||||||
#else
|
|
||||||
# define GMOCK_WCHAR_T_IS_NATIVE_ 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// signed wchar_t and unsigned wchar_t are NOT in the C++ standard.
|
|
||||||
// Using them is a bad practice and not portable. So DON'T use them.
|
|
||||||
//
|
|
||||||
// Still, Google Mock is designed to work even if the user uses signed
|
|
||||||
// wchar_t or unsigned wchar_t (obviously, assuming the compiler
|
|
||||||
// supports them).
|
|
||||||
//
|
|
||||||
// To gcc,
|
|
||||||
// wchar_t == signed wchar_t != unsigned wchar_t == unsigned int
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#if !defined(__WCHAR_UNSIGNED__)
|
|
||||||
// signed/unsigned wchar_t are valid types.
|
|
||||||
# define GMOCK_HAS_SIGNED_WCHAR_T_ 1
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// In what follows, we use the term "kind" to indicate whether a type
|
|
||||||
// is bool, an integer type (excluding bool), a floating-point type,
|
|
||||||
// or none of them. This categorization is useful for determining
|
|
||||||
// when a matcher argument type can be safely converted to another
|
|
||||||
// type in the implementation of SafeMatcherCast.
|
|
||||||
enum TypeKind {
|
|
||||||
kBool, kInteger, kFloatingPoint, kOther
|
|
||||||
};
|
|
||||||
|
|
||||||
// KindOf<T>::value is the kind of type T.
|
|
||||||
template <typename T> struct KindOf {
|
|
||||||
enum { value = kOther }; // The default kind.
|
|
||||||
};
|
|
||||||
|
|
||||||
// This macro declares that the kind of 'type' is 'kind'.
|
|
||||||
#define GMOCK_DECLARE_KIND_(type, kind) \
|
|
||||||
template <> struct KindOf<type> { enum { value = kind }; }
|
|
||||||
|
|
||||||
GMOCK_DECLARE_KIND_(bool, kBool);
|
|
||||||
|
|
||||||
// All standard integer types.
|
|
||||||
GMOCK_DECLARE_KIND_(char, kInteger);
|
|
||||||
GMOCK_DECLARE_KIND_(signed char, kInteger);
|
|
||||||
GMOCK_DECLARE_KIND_(unsigned char, kInteger);
|
|
||||||
GMOCK_DECLARE_KIND_(short, kInteger); // NOLINT
|
|
||||||
GMOCK_DECLARE_KIND_(unsigned short, kInteger); // NOLINT
|
|
||||||
GMOCK_DECLARE_KIND_(int, kInteger);
|
|
||||||
GMOCK_DECLARE_KIND_(unsigned int, kInteger);
|
|
||||||
GMOCK_DECLARE_KIND_(long, kInteger); // NOLINT
|
|
||||||
GMOCK_DECLARE_KIND_(unsigned long, kInteger); // NOLINT
|
|
||||||
|
|
||||||
#if GMOCK_WCHAR_T_IS_NATIVE_
|
|
||||||
GMOCK_DECLARE_KIND_(wchar_t, kInteger);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Non-standard integer types.
|
|
||||||
GMOCK_DECLARE_KIND_(Int64, kInteger);
|
|
||||||
GMOCK_DECLARE_KIND_(UInt64, kInteger);
|
|
||||||
|
|
||||||
// All standard floating-point types.
|
|
||||||
GMOCK_DECLARE_KIND_(float, kFloatingPoint);
|
|
||||||
GMOCK_DECLARE_KIND_(double, kFloatingPoint);
|
|
||||||
GMOCK_DECLARE_KIND_(long double, kFloatingPoint);
|
|
||||||
|
|
||||||
#undef GMOCK_DECLARE_KIND_
|
|
||||||
|
|
||||||
// Evaluates to the kind of 'type'.
|
|
||||||
#define GMOCK_KIND_OF_(type) \
|
|
||||||
static_cast< ::testing::internal::TypeKind>( \
|
|
||||||
::testing::internal::KindOf<type>::value)
|
|
||||||
|
|
||||||
// Evaluates to true iff integer type T is signed.
|
|
||||||
#define GMOCK_IS_SIGNED_(T) (static_cast<T>(-1) < 0)
|
|
||||||
|
|
||||||
// LosslessArithmeticConvertibleImpl<kFromKind, From, kToKind, To>::value
|
|
||||||
// is true iff arithmetic type From can be losslessly converted to
|
|
||||||
// arithmetic type To.
|
|
||||||
//
|
|
||||||
// It's the user's responsibility to ensure that both From and To are
|
|
||||||
// raw (i.e. has no CV modifier, is not a pointer, and is not a
|
|
||||||
// reference) built-in arithmetic types, kFromKind is the kind of
|
|
||||||
// From, and kToKind is the kind of To; the value is
|
|
||||||
// implementation-defined when the above pre-condition is violated.
|
|
||||||
template <TypeKind kFromKind, typename From, TypeKind kToKind, typename To>
|
|
||||||
struct LosslessArithmeticConvertibleImpl : public false_type {};
|
|
||||||
|
|
||||||
// Converting bool to bool is lossless.
|
|
||||||
template <>
|
|
||||||
struct LosslessArithmeticConvertibleImpl<kBool, bool, kBool, bool>
|
|
||||||
: public true_type {}; // NOLINT
|
|
||||||
|
|
||||||
// Converting bool to any integer type is lossless.
|
|
||||||
template <typename To>
|
|
||||||
struct LosslessArithmeticConvertibleImpl<kBool, bool, kInteger, To>
|
|
||||||
: public true_type {}; // NOLINT
|
|
||||||
|
|
||||||
// Converting bool to any floating-point type is lossless.
|
|
||||||
template <typename To>
|
|
||||||
struct LosslessArithmeticConvertibleImpl<kBool, bool, kFloatingPoint, To>
|
|
||||||
: public true_type {}; // NOLINT
|
|
||||||
|
|
||||||
// Converting an integer to bool is lossy.
|
|
||||||
template <typename From>
|
|
||||||
struct LosslessArithmeticConvertibleImpl<kInteger, From, kBool, bool>
|
|
||||||
: public false_type {}; // NOLINT
|
|
||||||
|
|
||||||
// Converting an integer to another non-bool integer is lossless iff
|
|
||||||
// the target type's range encloses the source type's range.
|
|
||||||
template <typename From, typename To>
|
|
||||||
struct LosslessArithmeticConvertibleImpl<kInteger, From, kInteger, To>
|
|
||||||
: public bool_constant<
|
|
||||||
// When converting from a smaller size to a larger size, we are
|
|
||||||
// fine as long as we are not converting from signed to unsigned.
|
|
||||||
((sizeof(From) < sizeof(To)) &&
|
|
||||||
(!GMOCK_IS_SIGNED_(From) || GMOCK_IS_SIGNED_(To))) ||
|
|
||||||
// When converting between the same size, the signedness must match.
|
|
||||||
((sizeof(From) == sizeof(To)) &&
|
|
||||||
(GMOCK_IS_SIGNED_(From) == GMOCK_IS_SIGNED_(To)))> {}; // NOLINT
|
|
||||||
|
|
||||||
#undef GMOCK_IS_SIGNED_
|
|
||||||
|
|
||||||
// Converting an integer to a floating-point type may be lossy, since
|
|
||||||
// the format of a floating-point number is implementation-defined.
|
|
||||||
template <typename From, typename To>
|
|
||||||
struct LosslessArithmeticConvertibleImpl<kInteger, From, kFloatingPoint, To>
|
|
||||||
: public false_type {}; // NOLINT
|
|
||||||
|
|
||||||
// Converting a floating-point to bool is lossy.
|
|
||||||
template <typename From>
|
|
||||||
struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kBool, bool>
|
|
||||||
: public false_type {}; // NOLINT
|
|
||||||
|
|
||||||
// Converting a floating-point to an integer is lossy.
|
|
||||||
template <typename From, typename To>
|
|
||||||
struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kInteger, To>
|
|
||||||
: public false_type {}; // NOLINT
|
|
||||||
|
|
||||||
// Converting a floating-point to another floating-point is lossless
|
|
||||||
// iff the target type is at least as big as the source type.
|
|
||||||
template <typename From, typename To>
|
|
||||||
struct LosslessArithmeticConvertibleImpl<
|
|
||||||
kFloatingPoint, From, kFloatingPoint, To>
|
|
||||||
: public bool_constant<sizeof(From) <= sizeof(To)> {}; // NOLINT
|
|
||||||
|
|
||||||
// LosslessArithmeticConvertible<From, To>::value is true iff arithmetic
|
|
||||||
// type From can be losslessly converted to arithmetic type To.
|
|
||||||
//
|
|
||||||
// It's the user's responsibility to ensure that both From and To are
|
|
||||||
// raw (i.e. has no CV modifier, is not a pointer, and is not a
|
|
||||||
// reference) built-in arithmetic types; the value is
|
|
||||||
// implementation-defined when the above pre-condition is violated.
|
|
||||||
template <typename From, typename To>
|
|
||||||
struct LosslessArithmeticConvertible
|
|
||||||
: public LosslessArithmeticConvertibleImpl<
|
|
||||||
GMOCK_KIND_OF_(From), From, GMOCK_KIND_OF_(To), To> {}; // NOLINT
|
|
||||||
|
|
||||||
// This interface knows how to report a Google Mock failure (either
|
|
||||||
// non-fatal or fatal).
|
|
||||||
class FailureReporterInterface {
|
|
||||||
public:
|
|
||||||
// The type of a failure (either non-fatal or fatal).
|
|
||||||
enum FailureType {
|
|
||||||
kNonfatal, kFatal
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual ~FailureReporterInterface() {}
|
|
||||||
|
|
||||||
// Reports a failure that occurred at the given source file location.
|
|
||||||
virtual void ReportFailure(FailureType type, const char* file, int line,
|
|
||||||
const std::string& message) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Returns the failure reporter used by Google Mock.
|
|
||||||
GTEST_API_ FailureReporterInterface* GetFailureReporter();
|
|
||||||
|
|
||||||
// Asserts that condition is true; aborts the process with the given
|
|
||||||
// message if condition is false. We cannot use LOG(FATAL) or CHECK()
|
|
||||||
// as Google Mock might be used to mock the log sink itself. We
|
|
||||||
// inline this function to prevent it from showing up in the stack
|
|
||||||
// trace.
|
|
||||||
inline void Assert(bool condition, const char* file, int line,
|
|
||||||
const std::string& msg) {
|
|
||||||
if (!condition) {
|
|
||||||
GetFailureReporter()->ReportFailure(FailureReporterInterface::kFatal,
|
|
||||||
file, line, msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
inline void Assert(bool condition, const char* file, int line) {
|
|
||||||
Assert(condition, file, line, "Assertion failed.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verifies that condition is true; generates a non-fatal failure if
|
|
||||||
// condition is false.
|
|
||||||
inline void Expect(bool condition, const char* file, int line,
|
|
||||||
const std::string& msg) {
|
|
||||||
if (!condition) {
|
|
||||||
GetFailureReporter()->ReportFailure(FailureReporterInterface::kNonfatal,
|
|
||||||
file, line, msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
inline void Expect(bool condition, const char* file, int line) {
|
|
||||||
Expect(condition, file, line, "Expectation failed.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Severity level of a log.
|
|
||||||
enum LogSeverity {
|
|
||||||
kInfo = 0,
|
|
||||||
kWarning = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
// Valid values for the --gmock_verbose flag.
|
|
||||||
|
|
||||||
// All logs (informational and warnings) are printed.
|
|
||||||
const char kInfoVerbosity[] = "info";
|
|
||||||
// Only warnings are printed.
|
|
||||||
const char kWarningVerbosity[] = "warning";
|
|
||||||
// No logs are printed.
|
|
||||||
const char kErrorVerbosity[] = "error";
|
|
||||||
|
|
||||||
// Returns true iff a log with the given severity is visible according
|
|
||||||
// to the --gmock_verbose flag.
|
|
||||||
GTEST_API_ bool LogIsVisible(LogSeverity severity);
|
|
||||||
|
|
||||||
// Prints the given message to stdout iff 'severity' >= the level
|
|
||||||
// specified by the --gmock_verbose flag. If stack_frames_to_skip >=
|
|
||||||
// 0, also prints the stack trace excluding the top
|
|
||||||
// stack_frames_to_skip frames. In opt mode, any positive
|
|
||||||
// stack_frames_to_skip is treated as 0, since we don't know which
|
|
||||||
// function calls will be inlined by the compiler and need to be
|
|
||||||
// conservative.
|
|
||||||
GTEST_API_ void Log(LogSeverity severity, const std::string& message,
|
|
||||||
int stack_frames_to_skip);
|
|
||||||
|
|
||||||
// A marker class that is used to resolve parameterless expectations to the
|
|
||||||
// correct overload. This must not be instantiable, to prevent client code from
|
|
||||||
// accidentally resolving to the overload; for example:
|
|
||||||
//
|
|
||||||
// ON_CALL(mock, Method({}, nullptr))...
|
|
||||||
//
|
|
||||||
class WithoutMatchers {
|
|
||||||
private:
|
|
||||||
WithoutMatchers() {}
|
|
||||||
friend GTEST_API_ WithoutMatchers GetWithoutMatchers();
|
|
||||||
};
|
|
||||||
|
|
||||||
// Internal use only: access the singleton instance of WithoutMatchers.
|
|
||||||
GTEST_API_ WithoutMatchers GetWithoutMatchers();
|
|
||||||
|
|
||||||
// FIXME: group all type utilities together.
|
|
||||||
|
|
||||||
// Type traits.
|
|
||||||
|
|
||||||
// is_reference<T>::value is non-zero iff T is a reference type.
|
|
||||||
template <typename T> struct is_reference : public false_type {};
|
|
||||||
template <typename T> struct is_reference<T&> : public true_type {};
|
|
||||||
|
|
||||||
// type_equals<T1, T2>::value is non-zero iff T1 and T2 are the same type.
|
|
||||||
template <typename T1, typename T2> struct type_equals : public false_type {};
|
|
||||||
template <typename T> struct type_equals<T, T> : public true_type {};
|
|
||||||
|
|
||||||
// remove_reference<T>::type removes the reference from type T, if any.
|
|
||||||
template <typename T> struct remove_reference { typedef T type; }; // NOLINT
|
|
||||||
template <typename T> struct remove_reference<T&> { typedef T type; }; // NOLINT
|
|
||||||
|
|
||||||
// DecayArray<T>::type turns an array type U[N] to const U* and preserves
|
|
||||||
// other types. Useful for saving a copy of a function argument.
|
|
||||||
template <typename T> struct DecayArray { typedef T type; }; // NOLINT
|
|
||||||
template <typename T, size_t N> struct DecayArray<T[N]> {
|
|
||||||
typedef const T* type;
|
|
||||||
};
|
|
||||||
// Sometimes people use arrays whose size is not available at the use site
|
|
||||||
// (e.g. extern const char kNamePrefix[]). This specialization covers that
|
|
||||||
// case.
|
|
||||||
template <typename T> struct DecayArray<T[]> {
|
|
||||||
typedef const T* type;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Disable MSVC warnings for infinite recursion, since in this case the
|
|
||||||
// the recursion is unreachable.
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
# pragma warning(push)
|
|
||||||
# pragma warning(disable:4717)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Invalid<T>() is usable as an expression of type T, but will terminate
|
|
||||||
// the program with an assertion failure if actually run. This is useful
|
|
||||||
// when a value of type T is needed for compilation, but the statement
|
|
||||||
// will not really be executed (or we don't care if the statement
|
|
||||||
// crashes).
|
|
||||||
template <typename T>
|
|
||||||
inline T Invalid() {
|
|
||||||
Assert(false, "", -1, "Internal error: attempt to return invalid value");
|
|
||||||
// This statement is unreachable, and would never terminate even if it
|
|
||||||
// could be reached. It is provided only to placate compiler warnings
|
|
||||||
// about missing return statements.
|
|
||||||
return Invalid<T>();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
# pragma warning(pop)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Given a raw type (i.e. having no top-level reference or const
|
|
||||||
// modifier) RawContainer that's either an STL-style container or a
|
|
||||||
// native array, class StlContainerView<RawContainer> has the
|
|
||||||
// following members:
|
|
||||||
//
|
|
||||||
// - type is a type that provides an STL-style container view to
|
|
||||||
// (i.e. implements the STL container concept for) RawContainer;
|
|
||||||
// - const_reference is a type that provides a reference to a const
|
|
||||||
// RawContainer;
|
|
||||||
// - ConstReference(raw_container) returns a const reference to an STL-style
|
|
||||||
// container view to raw_container, which is a RawContainer.
|
|
||||||
// - Copy(raw_container) returns an STL-style container view of a
|
|
||||||
// copy of raw_container, which is a RawContainer.
|
|
||||||
//
|
|
||||||
// This generic version is used when RawContainer itself is already an
|
|
||||||
// STL-style container.
|
|
||||||
template <class RawContainer>
|
|
||||||
class StlContainerView {
|
|
||||||
public:
|
|
||||||
typedef RawContainer type;
|
|
||||||
typedef const type& const_reference;
|
|
||||||
|
|
||||||
static const_reference ConstReference(const RawContainer& container) {
|
|
||||||
// Ensures that RawContainer is not a const type.
|
|
||||||
testing::StaticAssertTypeEq<RawContainer,
|
|
||||||
GTEST_REMOVE_CONST_(RawContainer)>();
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
static type Copy(const RawContainer& container) { return container; }
|
|
||||||
};
|
|
||||||
|
|
||||||
// This specialization is used when RawContainer is a native array type.
|
|
||||||
template <typename Element, size_t N>
|
|
||||||
class StlContainerView<Element[N]> {
|
|
||||||
public:
|
|
||||||
typedef GTEST_REMOVE_CONST_(Element) RawElement;
|
|
||||||
typedef internal::NativeArray<RawElement> type;
|
|
||||||
// NativeArray<T> can represent a native array either by value or by
|
|
||||||
// reference (selected by a constructor argument), so 'const type'
|
|
||||||
// can be used to reference a const native array. We cannot
|
|
||||||
// 'typedef const type& const_reference' here, as that would mean
|
|
||||||
// ConstReference() has to return a reference to a local variable.
|
|
||||||
typedef const type const_reference;
|
|
||||||
|
|
||||||
static const_reference ConstReference(const Element (&array)[N]) {
|
|
||||||
// Ensures that Element is not a const type.
|
|
||||||
testing::StaticAssertTypeEq<Element, RawElement>();
|
|
||||||
#if GTEST_OS_SYMBIAN
|
|
||||||
// The Nokia Symbian compiler confuses itself in template instantiation
|
|
||||||
// for this call without the cast to Element*:
|
|
||||||
// function call '[testing::internal::NativeArray<char *>].NativeArray(
|
|
||||||
// {lval} const char *[4], long, testing::internal::RelationToSource)'
|
|
||||||
// does not match
|
|
||||||
// 'testing::internal::NativeArray<char *>::NativeArray(
|
|
||||||
// char *const *, unsigned int, testing::internal::RelationToSource)'
|
|
||||||
// (instantiating: 'testing::internal::ContainsMatcherImpl
|
|
||||||
// <const char * (&)[4]>::Matches(const char * (&)[4]) const')
|
|
||||||
// (instantiating: 'testing::internal::StlContainerView<char *[4]>::
|
|
||||||
// ConstReference(const char * (&)[4])')
|
|
||||||
// (and though the N parameter type is mismatched in the above explicit
|
|
||||||
// conversion of it doesn't help - only the conversion of the array).
|
|
||||||
return type(const_cast<Element*>(&array[0]), N,
|
|
||||||
RelationToSourceReference());
|
|
||||||
#else
|
|
||||||
return type(array, N, RelationToSourceReference());
|
|
||||||
#endif // GTEST_OS_SYMBIAN
|
|
||||||
}
|
|
||||||
static type Copy(const Element (&array)[N]) {
|
|
||||||
#if GTEST_OS_SYMBIAN
|
|
||||||
return type(const_cast<Element*>(&array[0]), N, RelationToSourceCopy());
|
|
||||||
#else
|
|
||||||
return type(array, N, RelationToSourceCopy());
|
|
||||||
#endif // GTEST_OS_SYMBIAN
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// This specialization is used when RawContainer is a native array
|
|
||||||
// represented as a (pointer, size) tuple.
|
|
||||||
template <typename ElementPointer, typename Size>
|
|
||||||
class StlContainerView< ::testing::tuple<ElementPointer, Size> > {
|
|
||||||
public:
|
|
||||||
typedef GTEST_REMOVE_CONST_(
|
|
||||||
typename internal::PointeeOf<ElementPointer>::type) RawElement;
|
|
||||||
typedef internal::NativeArray<RawElement> type;
|
|
||||||
typedef const type const_reference;
|
|
||||||
|
|
||||||
static const_reference ConstReference(
|
|
||||||
const ::testing::tuple<ElementPointer, Size>& array) {
|
|
||||||
return type(get<0>(array), get<1>(array), RelationToSourceReference());
|
|
||||||
}
|
|
||||||
static type Copy(const ::testing::tuple<ElementPointer, Size>& array) {
|
|
||||||
return type(get<0>(array), get<1>(array), RelationToSourceCopy());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// The following specialization prevents the user from instantiating
|
|
||||||
// StlContainer with a reference type.
|
|
||||||
template <typename T> class StlContainerView<T&>;
|
|
||||||
|
|
||||||
// A type transform to remove constness from the first part of a pair.
|
|
||||||
// Pairs like that are used as the value_type of associative containers,
|
|
||||||
// and this transform produces a similar but assignable pair.
|
|
||||||
template <typename T>
|
|
||||||
struct RemoveConstFromKey {
|
|
||||||
typedef T type;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Partially specialized to remove constness from std::pair<const K, V>.
|
|
||||||
template <typename K, typename V>
|
|
||||||
struct RemoveConstFromKey<std::pair<const K, V> > {
|
|
||||||
typedef std::pair<K, V> type;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Mapping from booleans to types. Similar to boost::bool_<kValue> and
|
|
||||||
// std::integral_constant<bool, kValue>.
|
|
||||||
template <bool kValue>
|
|
||||||
struct BooleanConstant {};
|
|
||||||
|
|
||||||
// Emit an assertion failure due to incorrect DoDefault() usage. Out-of-lined to
|
|
||||||
// reduce code size.
|
|
||||||
GTEST_API_ void IllegalDoDefault(const char* file, int line);
|
|
||||||
|
|
||||||
#if GTEST_LANG_CXX11
|
|
||||||
// Helper types for Apply() below.
|
|
||||||
template <size_t... Is> struct int_pack { typedef int_pack type; };
|
|
||||||
|
|
||||||
template <class Pack, size_t I> struct append;
|
|
||||||
template <size_t... Is, size_t I>
|
|
||||||
struct append<int_pack<Is...>, I> : int_pack<Is..., I> {};
|
|
||||||
|
|
||||||
template <size_t C>
|
|
||||||
struct make_int_pack : append<typename make_int_pack<C - 1>::type, C - 1> {};
|
|
||||||
template <> struct make_int_pack<0> : int_pack<> {};
|
|
||||||
|
|
||||||
template <typename F, typename Tuple, size_t... Idx>
|
|
||||||
auto ApplyImpl(F&& f, Tuple&& args, int_pack<Idx...>) -> decltype(
|
|
||||||
std::forward<F>(f)(std::get<Idx>(std::forward<Tuple>(args))...)) {
|
|
||||||
return std::forward<F>(f)(std::get<Idx>(std::forward<Tuple>(args))...);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply the function to a tuple of arguments.
|
|
||||||
template <typename F, typename Tuple>
|
|
||||||
auto Apply(F&& f, Tuple&& args)
|
|
||||||
-> decltype(ApplyImpl(std::forward<F>(f), std::forward<Tuple>(args),
|
|
||||||
make_int_pack<std::tuple_size<Tuple>::value>())) {
|
|
||||||
return ApplyImpl(std::forward<F>(f), std::forward<Tuple>(args),
|
|
||||||
make_int_pack<std::tuple_size<Tuple>::value>());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
# pragma warning(pop)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
} // namespace testing
|
|
||||||
|
|
||||||
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
// Copyright 2008, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
//
|
|
||||||
// Low-level types and utilities for porting Google Mock to various
|
|
||||||
// platforms. All macros ending with _ and symbols defined in an
|
|
||||||
// internal namespace are subject to change without notice. Code
|
|
||||||
// outside Google Mock MUST NOT USE THEM DIRECTLY. Macros that don't
|
|
||||||
// end with _ are part of Google Mock's public API and can be used by
|
|
||||||
// code outside Google Mock.
|
|
||||||
|
|
||||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
|
||||||
|
|
||||||
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
|
|
||||||
#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
// Most of the utilities needed for porting Google Mock are also
|
|
||||||
// required for Google Test and are defined in gtest-port.h.
|
|
||||||
//
|
|
||||||
// Note to maintainers: to reduce code duplication, prefer adding
|
|
||||||
// portability utilities to Google Test's gtest-port.h instead of
|
|
||||||
// here, as Google Mock depends on Google Test. Only add a utility
|
|
||||||
// here if it's truly specific to Google Mock.
|
|
||||||
|
|
||||||
#include "gtest/internal/gtest-linked_ptr.h"
|
|
||||||
#include "gtest/internal/gtest-port.h"
|
|
||||||
#include "gmock/internal/custom/gmock-port.h"
|
|
||||||
|
|
||||||
// For MS Visual C++, check the compiler version. At least VS 2003 is
|
|
||||||
// required to compile Google Mock.
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER < 1310
|
|
||||||
# error "At least Visual C++ 2003 (7.1) is required to compile Google Mock."
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Macro for referencing flags. This is public as we want the user to
|
|
||||||
// use this syntax to reference Google Mock flags.
|
|
||||||
#define GMOCK_FLAG(name) FLAGS_gmock_##name
|
|
||||||
|
|
||||||
#if !defined(GMOCK_DECLARE_bool_)
|
|
||||||
|
|
||||||
// Macros for declaring flags.
|
|
||||||
# define GMOCK_DECLARE_bool_(name) extern GTEST_API_ bool GMOCK_FLAG(name)
|
|
||||||
# define GMOCK_DECLARE_int32_(name) \
|
|
||||||
extern GTEST_API_ ::testing::internal::Int32 GMOCK_FLAG(name)
|
|
||||||
# define GMOCK_DECLARE_string_(name) \
|
|
||||||
extern GTEST_API_ ::std::string GMOCK_FLAG(name)
|
|
||||||
|
|
||||||
// Macros for defining flags.
|
|
||||||
# define GMOCK_DEFINE_bool_(name, default_val, doc) \
|
|
||||||
GTEST_API_ bool GMOCK_FLAG(name) = (default_val)
|
|
||||||
# define GMOCK_DEFINE_int32_(name, default_val, doc) \
|
|
||||||
GTEST_API_ ::testing::internal::Int32 GMOCK_FLAG(name) = (default_val)
|
|
||||||
# define GMOCK_DEFINE_string_(name, default_val, doc) \
|
|
||||||
GTEST_API_ ::std::string GMOCK_FLAG(name) = (default_val)
|
|
||||||
|
|
||||||
#endif // !defined(GMOCK_DECLARE_bool_)
|
|
||||||
|
|
||||||
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
|
|
||||||
@@ -1,344 +0,0 @@
|
|||||||
// Copyright 2005, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
//
|
|
||||||
// The Google C++ Testing and Mocking Framework (Google Test)
|
|
||||||
//
|
|
||||||
// This header file defines the public API for death tests. It is
|
|
||||||
// #included by gtest.h so a user doesn't need to include this
|
|
||||||
// directly.
|
|
||||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
|
||||||
|
|
||||||
#ifndef GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
|
|
||||||
#define GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
|
|
||||||
|
|
||||||
#include "gtest/internal/gtest-death-test-internal.h"
|
|
||||||
|
|
||||||
namespace testing {
|
|
||||||
|
|
||||||
// This flag controls the style of death tests. Valid values are "threadsafe",
|
|
||||||
// meaning that the death test child process will re-execute the test binary
|
|
||||||
// from the start, running only a single death test, or "fast",
|
|
||||||
// meaning that the child process will execute the test logic immediately
|
|
||||||
// after forking.
|
|
||||||
GTEST_DECLARE_string_(death_test_style);
|
|
||||||
|
|
||||||
#if GTEST_HAS_DEATH_TEST
|
|
||||||
|
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
// Returns a Boolean value indicating whether the caller is currently
|
|
||||||
// executing in the context of the death test child process. Tools such as
|
|
||||||
// Valgrind heap checkers may need this to modify their behavior in death
|
|
||||||
// tests. IMPORTANT: This is an internal utility. Using it may break the
|
|
||||||
// implementation of death tests. User code MUST NOT use it.
|
|
||||||
GTEST_API_ bool InDeathTestChild();
|
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
|
|
||||||
// The following macros are useful for writing death tests.
|
|
||||||
|
|
||||||
// Here's what happens when an ASSERT_DEATH* or EXPECT_DEATH* is
|
|
||||||
// executed:
|
|
||||||
//
|
|
||||||
// 1. It generates a warning if there is more than one active
|
|
||||||
// thread. This is because it's safe to fork() or clone() only
|
|
||||||
// when there is a single thread.
|
|
||||||
//
|
|
||||||
// 2. The parent process clone()s a sub-process and runs the death
|
|
||||||
// test in it; the sub-process exits with code 0 at the end of the
|
|
||||||
// death test, if it hasn't exited already.
|
|
||||||
//
|
|
||||||
// 3. The parent process waits for the sub-process to terminate.
|
|
||||||
//
|
|
||||||
// 4. The parent process checks the exit code and error message of
|
|
||||||
// the sub-process.
|
|
||||||
//
|
|
||||||
// Examples:
|
|
||||||
//
|
|
||||||
// ASSERT_DEATH(server.SendMessage(56, "Hello"), "Invalid port number");
|
|
||||||
// for (int i = 0; i < 5; i++) {
|
|
||||||
// EXPECT_DEATH(server.ProcessRequest(i),
|
|
||||||
// "Invalid request .* in ProcessRequest()")
|
|
||||||
// << "Failed to die on request " << i;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// ASSERT_EXIT(server.ExitNow(), ::testing::ExitedWithCode(0), "Exiting");
|
|
||||||
//
|
|
||||||
// bool KilledBySIGHUP(int exit_code) {
|
|
||||||
// return WIFSIGNALED(exit_code) && WTERMSIG(exit_code) == SIGHUP;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// ASSERT_EXIT(client.HangUpServer(), KilledBySIGHUP, "Hanging up!");
|
|
||||||
//
|
|
||||||
// On the regular expressions used in death tests:
|
|
||||||
//
|
|
||||||
// GOOGLETEST_CM0005 DO NOT DELETE
|
|
||||||
// On POSIX-compliant systems (*nix), we use the <regex.h> library,
|
|
||||||
// which uses the POSIX extended regex syntax.
|
|
||||||
//
|
|
||||||
// On other platforms (e.g. Windows or Mac), we only support a simple regex
|
|
||||||
// syntax implemented as part of Google Test. This limited
|
|
||||||
// implementation should be enough most of the time when writing
|
|
||||||
// death tests; though it lacks many features you can find in PCRE
|
|
||||||
// or POSIX extended regex syntax. For example, we don't support
|
|
||||||
// union ("x|y"), grouping ("(xy)"), brackets ("[xy]"), and
|
|
||||||
// repetition count ("x{5,7}"), among others.
|
|
||||||
//
|
|
||||||
// Below is the syntax that we do support. We chose it to be a
|
|
||||||
// subset of both PCRE and POSIX extended regex, so it's easy to
|
|
||||||
// learn wherever you come from. In the following: 'A' denotes a
|
|
||||||
// literal character, period (.), or a single \\ escape sequence;
|
|
||||||
// 'x' and 'y' denote regular expressions; 'm' and 'n' are for
|
|
||||||
// natural numbers.
|
|
||||||
//
|
|
||||||
// c matches any literal character c
|
|
||||||
// \\d matches any decimal digit
|
|
||||||
// \\D matches any character that's not a decimal digit
|
|
||||||
// \\f matches \f
|
|
||||||
// \\n matches \n
|
|
||||||
// \\r matches \r
|
|
||||||
// \\s matches any ASCII whitespace, including \n
|
|
||||||
// \\S matches any character that's not a whitespace
|
|
||||||
// \\t matches \t
|
|
||||||
// \\v matches \v
|
|
||||||
// \\w matches any letter, _, or decimal digit
|
|
||||||
// \\W matches any character that \\w doesn't match
|
|
||||||
// \\c matches any literal character c, which must be a punctuation
|
|
||||||
// . matches any single character except \n
|
|
||||||
// A? matches 0 or 1 occurrences of A
|
|
||||||
// A* matches 0 or many occurrences of A
|
|
||||||
// A+ matches 1 or many occurrences of A
|
|
||||||
// ^ matches the beginning of a string (not that of each line)
|
|
||||||
// $ matches the end of a string (not that of each line)
|
|
||||||
// xy matches x followed by y
|
|
||||||
//
|
|
||||||
// If you accidentally use PCRE or POSIX extended regex features
|
|
||||||
// not implemented by us, you will get a run-time failure. In that
|
|
||||||
// case, please try to rewrite your regular expression within the
|
|
||||||
// above syntax.
|
|
||||||
//
|
|
||||||
// This implementation is *not* meant to be as highly tuned or robust
|
|
||||||
// as a compiled regex library, but should perform well enough for a
|
|
||||||
// death test, which already incurs significant overhead by launching
|
|
||||||
// a child process.
|
|
||||||
//
|
|
||||||
// Known caveats:
|
|
||||||
//
|
|
||||||
// A "threadsafe" style death test obtains the path to the test
|
|
||||||
// program from argv[0] and re-executes it in the sub-process. For
|
|
||||||
// simplicity, the current implementation doesn't search the PATH
|
|
||||||
// when launching the sub-process. This means that the user must
|
|
||||||
// invoke the test program via a path that contains at least one
|
|
||||||
// path separator (e.g. path/to/foo_test and
|
|
||||||
// /absolute/path/to/bar_test are fine, but foo_test is not). This
|
|
||||||
// is rarely a problem as people usually don't put the test binary
|
|
||||||
// directory in PATH.
|
|
||||||
//
|
|
||||||
// FIXME: make thread-safe death tests search the PATH.
|
|
||||||
|
|
||||||
// Asserts that a given statement causes the program to exit, with an
|
|
||||||
// integer exit status that satisfies predicate, and emitting error output
|
|
||||||
// that matches regex.
|
|
||||||
# define ASSERT_EXIT(statement, predicate, regex) \
|
|
||||||
GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_FATAL_FAILURE_)
|
|
||||||
|
|
||||||
// Like ASSERT_EXIT, but continues on to successive tests in the
|
|
||||||
// test case, if any:
|
|
||||||
# define EXPECT_EXIT(statement, predicate, regex) \
|
|
||||||
GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_NONFATAL_FAILURE_)
|
|
||||||
|
|
||||||
// Asserts that a given statement causes the program to exit, either by
|
|
||||||
// explicitly exiting with a nonzero exit code or being killed by a
|
|
||||||
// signal, and emitting error output that matches regex.
|
|
||||||
# define ASSERT_DEATH(statement, regex) \
|
|
||||||
ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
|
|
||||||
|
|
||||||
// Like ASSERT_DEATH, but continues on to successive tests in the
|
|
||||||
// test case, if any:
|
|
||||||
# define EXPECT_DEATH(statement, regex) \
|
|
||||||
EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
|
|
||||||
|
|
||||||
// Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*:
|
|
||||||
|
|
||||||
// Tests that an exit code describes a normal exit with a given exit code.
|
|
||||||
class GTEST_API_ ExitedWithCode {
|
|
||||||
public:
|
|
||||||
explicit ExitedWithCode(int exit_code);
|
|
||||||
bool operator()(int exit_status) const;
|
|
||||||
private:
|
|
||||||
// No implementation - assignment is unsupported.
|
|
||||||
void operator=(const ExitedWithCode& other);
|
|
||||||
|
|
||||||
const int exit_code_;
|
|
||||||
};
|
|
||||||
|
|
||||||
# if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA
|
|
||||||
// Tests that an exit code describes an exit due to termination by a
|
|
||||||
// given signal.
|
|
||||||
// GOOGLETEST_CM0006 DO NOT DELETE
|
|
||||||
class GTEST_API_ KilledBySignal {
|
|
||||||
public:
|
|
||||||
explicit KilledBySignal(int signum);
|
|
||||||
bool operator()(int exit_status) const;
|
|
||||||
private:
|
|
||||||
const int signum_;
|
|
||||||
};
|
|
||||||
# endif // !GTEST_OS_WINDOWS
|
|
||||||
|
|
||||||
// EXPECT_DEBUG_DEATH asserts that the given statements die in debug mode.
|
|
||||||
// The death testing framework causes this to have interesting semantics,
|
|
||||||
// since the sideeffects of the call are only visible in opt mode, and not
|
|
||||||
// in debug mode.
|
|
||||||
//
|
|
||||||
// In practice, this can be used to test functions that utilize the
|
|
||||||
// LOG(DFATAL) macro using the following style:
|
|
||||||
//
|
|
||||||
// int DieInDebugOr12(int* sideeffect) {
|
|
||||||
// if (sideeffect) {
|
|
||||||
// *sideeffect = 12;
|
|
||||||
// }
|
|
||||||
// LOG(DFATAL) << "death";
|
|
||||||
// return 12;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// TEST(TestCase, TestDieOr12WorksInDgbAndOpt) {
|
|
||||||
// int sideeffect = 0;
|
|
||||||
// // Only asserts in dbg.
|
|
||||||
// EXPECT_DEBUG_DEATH(DieInDebugOr12(&sideeffect), "death");
|
|
||||||
//
|
|
||||||
// #ifdef NDEBUG
|
|
||||||
// // opt-mode has sideeffect visible.
|
|
||||||
// EXPECT_EQ(12, sideeffect);
|
|
||||||
// #else
|
|
||||||
// // dbg-mode no visible sideeffect.
|
|
||||||
// EXPECT_EQ(0, sideeffect);
|
|
||||||
// #endif
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// This will assert that DieInDebugReturn12InOpt() crashes in debug
|
|
||||||
// mode, usually due to a DCHECK or LOG(DFATAL), but returns the
|
|
||||||
// appropriate fallback value (12 in this case) in opt mode. If you
|
|
||||||
// need to test that a function has appropriate side-effects in opt
|
|
||||||
// mode, include assertions against the side-effects. A general
|
|
||||||
// pattern for this is:
|
|
||||||
//
|
|
||||||
// EXPECT_DEBUG_DEATH({
|
|
||||||
// // Side-effects here will have an effect after this statement in
|
|
||||||
// // opt mode, but none in debug mode.
|
|
||||||
// EXPECT_EQ(12, DieInDebugOr12(&sideeffect));
|
|
||||||
// }, "death");
|
|
||||||
//
|
|
||||||
# ifdef NDEBUG
|
|
||||||
|
|
||||||
# define EXPECT_DEBUG_DEATH(statement, regex) \
|
|
||||||
GTEST_EXECUTE_STATEMENT_(statement, regex)
|
|
||||||
|
|
||||||
# define ASSERT_DEBUG_DEATH(statement, regex) \
|
|
||||||
GTEST_EXECUTE_STATEMENT_(statement, regex)
|
|
||||||
|
|
||||||
# else
|
|
||||||
|
|
||||||
# define EXPECT_DEBUG_DEATH(statement, regex) \
|
|
||||||
EXPECT_DEATH(statement, regex)
|
|
||||||
|
|
||||||
# define ASSERT_DEBUG_DEATH(statement, regex) \
|
|
||||||
ASSERT_DEATH(statement, regex)
|
|
||||||
|
|
||||||
# endif // NDEBUG for EXPECT_DEBUG_DEATH
|
|
||||||
#endif // GTEST_HAS_DEATH_TEST
|
|
||||||
|
|
||||||
// This macro is used for implementing macros such as
|
|
||||||
// EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED on systems where
|
|
||||||
// death tests are not supported. Those macros must compile on such systems
|
|
||||||
// iff EXPECT_DEATH and ASSERT_DEATH compile with the same parameters on
|
|
||||||
// systems that support death tests. This allows one to write such a macro
|
|
||||||
// on a system that does not support death tests and be sure that it will
|
|
||||||
// compile on a death-test supporting system. It is exposed publicly so that
|
|
||||||
// systems that have death-tests with stricter requirements than
|
|
||||||
// GTEST_HAS_DEATH_TEST can write their own equivalent of
|
|
||||||
// EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED.
|
|
||||||
//
|
|
||||||
// Parameters:
|
|
||||||
// statement - A statement that a macro such as EXPECT_DEATH would test
|
|
||||||
// for program termination. This macro has to make sure this
|
|
||||||
// statement is compiled but not executed, to ensure that
|
|
||||||
// EXPECT_DEATH_IF_SUPPORTED compiles with a certain
|
|
||||||
// parameter iff EXPECT_DEATH compiles with it.
|
|
||||||
// regex - A regex that a macro such as EXPECT_DEATH would use to test
|
|
||||||
// the output of statement. This parameter has to be
|
|
||||||
// compiled but not evaluated by this macro, to ensure that
|
|
||||||
// this macro only accepts expressions that a macro such as
|
|
||||||
// EXPECT_DEATH would accept.
|
|
||||||
// terminator - Must be an empty statement for EXPECT_DEATH_IF_SUPPORTED
|
|
||||||
// and a return statement for ASSERT_DEATH_IF_SUPPORTED.
|
|
||||||
// This ensures that ASSERT_DEATH_IF_SUPPORTED will not
|
|
||||||
// compile inside functions where ASSERT_DEATH doesn't
|
|
||||||
// compile.
|
|
||||||
//
|
|
||||||
// The branch that has an always false condition is used to ensure that
|
|
||||||
// statement and regex are compiled (and thus syntactically correct) but
|
|
||||||
// never executed. The unreachable code macro protects the terminator
|
|
||||||
// statement from generating an 'unreachable code' warning in case
|
|
||||||
// statement unconditionally returns or throws. The Message constructor at
|
|
||||||
// the end allows the syntax of streaming additional messages into the
|
|
||||||
// macro, for compilational compatibility with EXPECT_DEATH/ASSERT_DEATH.
|
|
||||||
# define GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, terminator) \
|
|
||||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
|
||||||
if (::testing::internal::AlwaysTrue()) { \
|
|
||||||
GTEST_LOG_(WARNING) \
|
|
||||||
<< "Death tests are not supported on this platform.\n" \
|
|
||||||
<< "Statement '" #statement "' cannot be verified."; \
|
|
||||||
} else if (::testing::internal::AlwaysFalse()) { \
|
|
||||||
::testing::internal::RE::PartialMatch(".*", (regex)); \
|
|
||||||
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
|
|
||||||
terminator; \
|
|
||||||
} else \
|
|
||||||
::testing::Message()
|
|
||||||
|
|
||||||
// EXPECT_DEATH_IF_SUPPORTED(statement, regex) and
|
|
||||||
// ASSERT_DEATH_IF_SUPPORTED(statement, regex) expand to real death tests if
|
|
||||||
// death tests are supported; otherwise they just issue a warning. This is
|
|
||||||
// useful when you are combining death test assertions with normal test
|
|
||||||
// assertions in one test.
|
|
||||||
#if GTEST_HAS_DEATH_TEST
|
|
||||||
# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
|
|
||||||
EXPECT_DEATH(statement, regex)
|
|
||||||
# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
|
|
||||||
ASSERT_DEATH(statement, regex)
|
|
||||||
#else
|
|
||||||
# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
|
|
||||||
GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, )
|
|
||||||
# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
|
|
||||||
GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, return)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace testing
|
|
||||||
|
|
||||||
#endif // GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
|
|
||||||
@@ -1,255 +0,0 @@
|
|||||||
// Copyright 2005, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
//
|
|
||||||
// The Google C++ Testing and Mocking Framework (Google Test)
|
|
||||||
//
|
|
||||||
// This header file defines the Message class.
|
|
||||||
//
|
|
||||||
// IMPORTANT NOTE: Due to limitation of the C++ language, we have to
|
|
||||||
// leave some internal implementation details in this header file.
|
|
||||||
// They are clearly marked by comments like this:
|
|
||||||
//
|
|
||||||
// // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
|
|
||||||
//
|
|
||||||
// Such code is NOT meant to be used by a user directly, and is subject
|
|
||||||
// to CHANGE WITHOUT NOTICE. Therefore DO NOT DEPEND ON IT in a user
|
|
||||||
// program!
|
|
||||||
|
|
||||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
|
||||||
|
|
||||||
#ifndef GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
|
|
||||||
#define GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
|
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
|
|
||||||
#include "gtest/internal/gtest-port.h"
|
|
||||||
|
|
||||||
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
|
|
||||||
/* class A needs to have dll-interface to be used by clients of class B */)
|
|
||||||
|
|
||||||
// Ensures that there is at least one operator<< in the global namespace.
|
|
||||||
// See Message& operator<<(...) below for why.
|
|
||||||
void operator<<(const testing::internal::Secret&, int);
|
|
||||||
|
|
||||||
namespace testing {
|
|
||||||
|
|
||||||
// The Message class works like an ostream repeater.
|
|
||||||
//
|
|
||||||
// Typical usage:
|
|
||||||
//
|
|
||||||
// 1. You stream a bunch of values to a Message object.
|
|
||||||
// It will remember the text in a stringstream.
|
|
||||||
// 2. Then you stream the Message object to an ostream.
|
|
||||||
// This causes the text in the Message to be streamed
|
|
||||||
// to the ostream.
|
|
||||||
//
|
|
||||||
// For example;
|
|
||||||
//
|
|
||||||
// testing::Message foo;
|
|
||||||
// foo << 1 << " != " << 2;
|
|
||||||
// std::cout << foo;
|
|
||||||
//
|
|
||||||
// will print "1 != 2".
|
|
||||||
//
|
|
||||||
// Message is not intended to be inherited from. In particular, its
|
|
||||||
// destructor is not virtual.
|
|
||||||
//
|
|
||||||
// Note that stringstream behaves differently in gcc and in MSVC. You
|
|
||||||
// can stream a NULL char pointer to it in the former, but not in the
|
|
||||||
// latter (it causes an access violation if you do). The Message
|
|
||||||
// class hides this difference by treating a NULL char pointer as
|
|
||||||
// "(null)".
|
|
||||||
class GTEST_API_ Message {
|
|
||||||
private:
|
|
||||||
// The type of basic IO manipulators (endl, ends, and flush) for
|
|
||||||
// narrow streams.
|
|
||||||
typedef std::ostream& (*BasicNarrowIoManip)(std::ostream&);
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Constructs an empty Message.
|
|
||||||
Message();
|
|
||||||
|
|
||||||
// Copy constructor.
|
|
||||||
Message(const Message& msg) : ss_(new ::std::stringstream) { // NOLINT
|
|
||||||
*ss_ << msg.GetString();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Constructs a Message from a C-string.
|
|
||||||
explicit Message(const char* str) : ss_(new ::std::stringstream) {
|
|
||||||
*ss_ << str;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if GTEST_OS_SYMBIAN
|
|
||||||
// Streams a value (either a pointer or not) to this object.
|
|
||||||
template <typename T>
|
|
||||||
inline Message& operator <<(const T& value) {
|
|
||||||
StreamHelper(typename internal::is_pointer<T>::type(), value);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// Streams a non-pointer value to this object.
|
|
||||||
template <typename T>
|
|
||||||
inline Message& operator <<(const T& val) {
|
|
||||||
// Some libraries overload << for STL containers. These
|
|
||||||
// overloads are defined in the global namespace instead of ::std.
|
|
||||||
//
|
|
||||||
// C++'s symbol lookup rule (i.e. Koenig lookup) says that these
|
|
||||||
// overloads are visible in either the std namespace or the global
|
|
||||||
// namespace, but not other namespaces, including the testing
|
|
||||||
// namespace which Google Test's Message class is in.
|
|
||||||
//
|
|
||||||
// To allow STL containers (and other types that has a << operator
|
|
||||||
// defined in the global namespace) to be used in Google Test
|
|
||||||
// assertions, testing::Message must access the custom << operator
|
|
||||||
// from the global namespace. With this using declaration,
|
|
||||||
// overloads of << defined in the global namespace and those
|
|
||||||
// visible via Koenig lookup are both exposed in this function.
|
|
||||||
using ::operator <<;
|
|
||||||
*ss_ << val;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Streams a pointer value to this object.
|
|
||||||
//
|
|
||||||
// This function is an overload of the previous one. When you
|
|
||||||
// stream a pointer to a Message, this definition will be used as it
|
|
||||||
// is more specialized. (The C++ Standard, section
|
|
||||||
// [temp.func.order].) If you stream a non-pointer, then the
|
|
||||||
// previous definition will be used.
|
|
||||||
//
|
|
||||||
// The reason for this overload is that streaming a NULL pointer to
|
|
||||||
// ostream is undefined behavior. Depending on the compiler, you
|
|
||||||
// may get "0", "(nil)", "(null)", or an access violation. To
|
|
||||||
// ensure consistent result across compilers, we always treat NULL
|
|
||||||
// as "(null)".
|
|
||||||
template <typename T>
|
|
||||||
inline Message& operator <<(T* const& pointer) { // NOLINT
|
|
||||||
if (pointer == NULL) {
|
|
||||||
*ss_ << "(null)";
|
|
||||||
} else {
|
|
||||||
*ss_ << pointer;
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
#endif // GTEST_OS_SYMBIAN
|
|
||||||
|
|
||||||
// Since the basic IO manipulators are overloaded for both narrow
|
|
||||||
// and wide streams, we have to provide this specialized definition
|
|
||||||
// of operator <<, even though its body is the same as the
|
|
||||||
// templatized version above. Without this definition, streaming
|
|
||||||
// endl or other basic IO manipulators to Message will confuse the
|
|
||||||
// compiler.
|
|
||||||
Message& operator <<(BasicNarrowIoManip val) {
|
|
||||||
*ss_ << val;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Instead of 1/0, we want to see true/false for bool values.
|
|
||||||
Message& operator <<(bool b) {
|
|
||||||
return *this << (b ? "true" : "false");
|
|
||||||
}
|
|
||||||
|
|
||||||
// These two overloads allow streaming a wide C string to a Message
|
|
||||||
// using the UTF-8 encoding.
|
|
||||||
Message& operator <<(const wchar_t* wide_c_str);
|
|
||||||
Message& operator <<(wchar_t* wide_c_str);
|
|
||||||
|
|
||||||
#if GTEST_HAS_STD_WSTRING
|
|
||||||
// Converts the given wide string to a narrow string using the UTF-8
|
|
||||||
// encoding, and streams the result to this Message object.
|
|
||||||
Message& operator <<(const ::std::wstring& wstr);
|
|
||||||
#endif // GTEST_HAS_STD_WSTRING
|
|
||||||
|
|
||||||
#if GTEST_HAS_GLOBAL_WSTRING
|
|
||||||
// Converts the given wide string to a narrow string using the UTF-8
|
|
||||||
// encoding, and streams the result to this Message object.
|
|
||||||
Message& operator <<(const ::wstring& wstr);
|
|
||||||
#endif // GTEST_HAS_GLOBAL_WSTRING
|
|
||||||
|
|
||||||
// Gets the text streamed to this object so far as an std::string.
|
|
||||||
// Each '\0' character in the buffer is replaced with "\\0".
|
|
||||||
//
|
|
||||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
|
|
||||||
std::string GetString() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
#if GTEST_OS_SYMBIAN
|
|
||||||
// These are needed as the Nokia Symbian Compiler cannot decide between
|
|
||||||
// const T& and const T* in a function template. The Nokia compiler _can_
|
|
||||||
// decide between class template specializations for T and T*, so a
|
|
||||||
// tr1::type_traits-like is_pointer works, and we can overload on that.
|
|
||||||
template <typename T>
|
|
||||||
inline void StreamHelper(internal::true_type /*is_pointer*/, T* pointer) {
|
|
||||||
if (pointer == NULL) {
|
|
||||||
*ss_ << "(null)";
|
|
||||||
} else {
|
|
||||||
*ss_ << pointer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
template <typename T>
|
|
||||||
inline void StreamHelper(internal::false_type /*is_pointer*/,
|
|
||||||
const T& value) {
|
|
||||||
// See the comments in Message& operator <<(const T&) above for why
|
|
||||||
// we need this using statement.
|
|
||||||
using ::operator <<;
|
|
||||||
*ss_ << value;
|
|
||||||
}
|
|
||||||
#endif // GTEST_OS_SYMBIAN
|
|
||||||
|
|
||||||
// We'll hold the text streamed to this object here.
|
|
||||||
const internal::scoped_ptr< ::std::stringstream> ss_;
|
|
||||||
|
|
||||||
// We declare (but don't implement) this to prevent the compiler
|
|
||||||
// from implementing the assignment operator.
|
|
||||||
void operator=(const Message&);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Streams a Message to an ostream.
|
|
||||||
inline std::ostream& operator <<(std::ostream& os, const Message& sb) {
|
|
||||||
return os << sb.GetString();
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
// Converts a streamable value to an std::string. A NULL pointer is
|
|
||||||
// converted to "(null)". When the input value is a ::string,
|
|
||||||
// ::std::string, ::wstring, or ::std::wstring object, each NUL
|
|
||||||
// character in it is replaced with "\\0".
|
|
||||||
template <typename T>
|
|
||||||
std::string StreamableToString(const T& streamable) {
|
|
||||||
return (Message() << streamable).GetString();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
} // namespace testing
|
|
||||||
|
|
||||||
GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
|
|
||||||
|
|
||||||
#endif // GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,500 +0,0 @@
|
|||||||
$$ -*- mode: c++; -*-
|
|
||||||
$var n = 50 $$ Maximum length of Values arguments we want to support.
|
|
||||||
$var maxtuple = 10 $$ Maximum number of Combine arguments we want to support.
|
|
||||||
// Copyright 2008, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
//
|
|
||||||
// Macros and functions for implementing parameterized tests
|
|
||||||
// in Google C++ Testing and Mocking Framework (Google Test)
|
|
||||||
//
|
|
||||||
// This file is generated by a SCRIPT. DO NOT EDIT BY HAND!
|
|
||||||
//
|
|
||||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
|
||||||
#ifndef GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
|
|
||||||
#define GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
|
|
||||||
|
|
||||||
|
|
||||||
// Value-parameterized tests allow you to test your code with different
|
|
||||||
// parameters without writing multiple copies of the same test.
|
|
||||||
//
|
|
||||||
// Here is how you use value-parameterized tests:
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
// To write value-parameterized tests, first you should define a fixture
|
|
||||||
// class. It is usually derived from testing::TestWithParam<T> (see below for
|
|
||||||
// another inheritance scheme that's sometimes useful in more complicated
|
|
||||||
// class hierarchies), where the type of your parameter values.
|
|
||||||
// TestWithParam<T> is itself derived from testing::Test. T can be any
|
|
||||||
// copyable type. If it's a raw pointer, you are responsible for managing the
|
|
||||||
// lifespan of the pointed values.
|
|
||||||
|
|
||||||
class FooTest : public ::testing::TestWithParam<const char*> {
|
|
||||||
// You can implement all the usual class fixture members here.
|
|
||||||
};
|
|
||||||
|
|
||||||
// Then, use the TEST_P macro to define as many parameterized tests
|
|
||||||
// for this fixture as you want. The _P suffix is for "parameterized"
|
|
||||||
// or "pattern", whichever you prefer to think.
|
|
||||||
|
|
||||||
TEST_P(FooTest, DoesBlah) {
|
|
||||||
// Inside a test, access the test parameter with the GetParam() method
|
|
||||||
// of the TestWithParam<T> class:
|
|
||||||
EXPECT_TRUE(foo.Blah(GetParam()));
|
|
||||||
...
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_P(FooTest, HasBlahBlah) {
|
|
||||||
...
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally, you can use INSTANTIATE_TEST_CASE_P to instantiate the test
|
|
||||||
// case with any set of parameters you want. Google Test defines a number
|
|
||||||
// of functions for generating test parameters. They return what we call
|
|
||||||
// (surprise!) parameter generators. Here is a summary of them, which
|
|
||||||
// are all in the testing namespace:
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Range(begin, end [, step]) - Yields values {begin, begin+step,
|
|
||||||
// begin+step+step, ...}. The values do not
|
|
||||||
// include end. step defaults to 1.
|
|
||||||
// Values(v1, v2, ..., vN) - Yields values {v1, v2, ..., vN}.
|
|
||||||
// ValuesIn(container) - Yields values from a C-style array, an STL
|
|
||||||
// ValuesIn(begin,end) container, or an iterator range [begin, end).
|
|
||||||
// Bool() - Yields sequence {false, true}.
|
|
||||||
// Combine(g1, g2, ..., gN) - Yields all combinations (the Cartesian product
|
|
||||||
// for the math savvy) of the values generated
|
|
||||||
// by the N generators.
|
|
||||||
//
|
|
||||||
// For more details, see comments at the definitions of these functions below
|
|
||||||
// in this file.
|
|
||||||
//
|
|
||||||
// The following statement will instantiate tests from the FooTest test case
|
|
||||||
// each with parameter values "meeny", "miny", and "moe".
|
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(InstantiationName,
|
|
||||||
FooTest,
|
|
||||||
Values("meeny", "miny", "moe"));
|
|
||||||
|
|
||||||
// To distinguish different instances of the pattern, (yes, you
|
|
||||||
// can instantiate it more then once) the first argument to the
|
|
||||||
// INSTANTIATE_TEST_CASE_P macro is a prefix that will be added to the
|
|
||||||
// actual test case name. Remember to pick unique prefixes for different
|
|
||||||
// instantiations. The tests from the instantiation above will have
|
|
||||||
// these names:
|
|
||||||
//
|
|
||||||
// * InstantiationName/FooTest.DoesBlah/0 for "meeny"
|
|
||||||
// * InstantiationName/FooTest.DoesBlah/1 for "miny"
|
|
||||||
// * InstantiationName/FooTest.DoesBlah/2 for "moe"
|
|
||||||
// * InstantiationName/FooTest.HasBlahBlah/0 for "meeny"
|
|
||||||
// * InstantiationName/FooTest.HasBlahBlah/1 for "miny"
|
|
||||||
// * InstantiationName/FooTest.HasBlahBlah/2 for "moe"
|
|
||||||
//
|
|
||||||
// You can use these names in --gtest_filter.
|
|
||||||
//
|
|
||||||
// This statement will instantiate all tests from FooTest again, each
|
|
||||||
// with parameter values "cat" and "dog":
|
|
||||||
|
|
||||||
const char* pets[] = {"cat", "dog"};
|
|
||||||
INSTANTIATE_TEST_CASE_P(AnotherInstantiationName, FooTest, ValuesIn(pets));
|
|
||||||
|
|
||||||
// The tests from the instantiation above will have these names:
|
|
||||||
//
|
|
||||||
// * AnotherInstantiationName/FooTest.DoesBlah/0 for "cat"
|
|
||||||
// * AnotherInstantiationName/FooTest.DoesBlah/1 for "dog"
|
|
||||||
// * AnotherInstantiationName/FooTest.HasBlahBlah/0 for "cat"
|
|
||||||
// * AnotherInstantiationName/FooTest.HasBlahBlah/1 for "dog"
|
|
||||||
//
|
|
||||||
// Please note that INSTANTIATE_TEST_CASE_P will instantiate all tests
|
|
||||||
// in the given test case, whether their definitions come before or
|
|
||||||
// AFTER the INSTANTIATE_TEST_CASE_P statement.
|
|
||||||
//
|
|
||||||
// Please also note that generator expressions (including parameters to the
|
|
||||||
// generators) are evaluated in InitGoogleTest(), after main() has started.
|
|
||||||
// This allows the user on one hand, to adjust generator parameters in order
|
|
||||||
// to dynamically determine a set of tests to run and on the other hand,
|
|
||||||
// give the user a chance to inspect the generated tests with Google Test
|
|
||||||
// reflection API before RUN_ALL_TESTS() is executed.
|
|
||||||
//
|
|
||||||
// You can see samples/sample7_unittest.cc and samples/sample8_unittest.cc
|
|
||||||
// for more examples.
|
|
||||||
//
|
|
||||||
// In the future, we plan to publish the API for defining new parameter
|
|
||||||
// generators. But for now this interface remains part of the internal
|
|
||||||
// implementation and is subject to change.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// A parameterized test fixture must be derived from testing::Test and from
|
|
||||||
// testing::WithParamInterface<T>, where T is the type of the parameter
|
|
||||||
// values. Inheriting from TestWithParam<T> satisfies that requirement because
|
|
||||||
// TestWithParam<T> inherits from both Test and WithParamInterface. In more
|
|
||||||
// complicated hierarchies, however, it is occasionally useful to inherit
|
|
||||||
// separately from Test and WithParamInterface. For example:
|
|
||||||
|
|
||||||
class BaseTest : public ::testing::Test {
|
|
||||||
// You can inherit all the usual members for a non-parameterized test
|
|
||||||
// fixture here.
|
|
||||||
};
|
|
||||||
|
|
||||||
class DerivedTest : public BaseTest, public ::testing::WithParamInterface<int> {
|
|
||||||
// The usual test fixture members go here too.
|
|
||||||
};
|
|
||||||
|
|
||||||
TEST_F(BaseTest, HasFoo) {
|
|
||||||
// This is an ordinary non-parameterized test.
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_P(DerivedTest, DoesBlah) {
|
|
||||||
// GetParam works just the same here as if you inherit from TestWithParam.
|
|
||||||
EXPECT_TRUE(foo.Blah(GetParam()));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // 0
|
|
||||||
|
|
||||||
#include "gtest/internal/gtest-port.h"
|
|
||||||
|
|
||||||
#if !GTEST_OS_SYMBIAN
|
|
||||||
# include <utility>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "gtest/internal/gtest-internal.h"
|
|
||||||
#include "gtest/internal/gtest-param-util.h"
|
|
||||||
#include "gtest/internal/gtest-param-util-generated.h"
|
|
||||||
|
|
||||||
namespace testing {
|
|
||||||
|
|
||||||
// Functions producing parameter generators.
|
|
||||||
//
|
|
||||||
// Google Test uses these generators to produce parameters for value-
|
|
||||||
// parameterized tests. When a parameterized test case is instantiated
|
|
||||||
// with a particular generator, Google Test creates and runs tests
|
|
||||||
// for each element in the sequence produced by the generator.
|
|
||||||
//
|
|
||||||
// In the following sample, tests from test case FooTest are instantiated
|
|
||||||
// each three times with parameter values 3, 5, and 8:
|
|
||||||
//
|
|
||||||
// class FooTest : public TestWithParam<int> { ... };
|
|
||||||
//
|
|
||||||
// TEST_P(FooTest, TestThis) {
|
|
||||||
// }
|
|
||||||
// TEST_P(FooTest, TestThat) {
|
|
||||||
// }
|
|
||||||
// INSTANTIATE_TEST_CASE_P(TestSequence, FooTest, Values(3, 5, 8));
|
|
||||||
//
|
|
||||||
|
|
||||||
// Range() returns generators providing sequences of values in a range.
|
|
||||||
//
|
|
||||||
// Synopsis:
|
|
||||||
// Range(start, end)
|
|
||||||
// - returns a generator producing a sequence of values {start, start+1,
|
|
||||||
// start+2, ..., }.
|
|
||||||
// Range(start, end, step)
|
|
||||||
// - returns a generator producing a sequence of values {start, start+step,
|
|
||||||
// start+step+step, ..., }.
|
|
||||||
// Notes:
|
|
||||||
// * The generated sequences never include end. For example, Range(1, 5)
|
|
||||||
// returns a generator producing a sequence {1, 2, 3, 4}. Range(1, 9, 2)
|
|
||||||
// returns a generator producing {1, 3, 5, 7}.
|
|
||||||
// * start and end must have the same type. That type may be any integral or
|
|
||||||
// floating-point type or a user defined type satisfying these conditions:
|
|
||||||
// * It must be assignable (have operator=() defined).
|
|
||||||
// * It must have operator+() (operator+(int-compatible type) for
|
|
||||||
// two-operand version).
|
|
||||||
// * It must have operator<() defined.
|
|
||||||
// Elements in the resulting sequences will also have that type.
|
|
||||||
// * Condition start < end must be satisfied in order for resulting sequences
|
|
||||||
// to contain any elements.
|
|
||||||
//
|
|
||||||
template <typename T, typename IncrementT>
|
|
||||||
internal::ParamGenerator<T> Range(T start, T end, IncrementT step) {
|
|
||||||
return internal::ParamGenerator<T>(
|
|
||||||
new internal::RangeGenerator<T, IncrementT>(start, end, step));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
internal::ParamGenerator<T> Range(T start, T end) {
|
|
||||||
return Range(start, end, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ValuesIn() function allows generation of tests with parameters coming from
|
|
||||||
// a container.
|
|
||||||
//
|
|
||||||
// Synopsis:
|
|
||||||
// ValuesIn(const T (&array)[N])
|
|
||||||
// - returns a generator producing sequences with elements from
|
|
||||||
// a C-style array.
|
|
||||||
// ValuesIn(const Container& container)
|
|
||||||
// - returns a generator producing sequences with elements from
|
|
||||||
// an STL-style container.
|
|
||||||
// ValuesIn(Iterator begin, Iterator end)
|
|
||||||
// - returns a generator producing sequences with elements from
|
|
||||||
// a range [begin, end) defined by a pair of STL-style iterators. These
|
|
||||||
// iterators can also be plain C pointers.
|
|
||||||
//
|
|
||||||
// Please note that ValuesIn copies the values from the containers
|
|
||||||
// passed in and keeps them to generate tests in RUN_ALL_TESTS().
|
|
||||||
//
|
|
||||||
// Examples:
|
|
||||||
//
|
|
||||||
// This instantiates tests from test case StringTest
|
|
||||||
// each with C-string values of "foo", "bar", and "baz":
|
|
||||||
//
|
|
||||||
// const char* strings[] = {"foo", "bar", "baz"};
|
|
||||||
// INSTANTIATE_TEST_CASE_P(StringSequence, StringTest, ValuesIn(strings));
|
|
||||||
//
|
|
||||||
// This instantiates tests from test case StlStringTest
|
|
||||||
// each with STL strings with values "a" and "b":
|
|
||||||
//
|
|
||||||
// ::std::vector< ::std::string> GetParameterStrings() {
|
|
||||||
// ::std::vector< ::std::string> v;
|
|
||||||
// v.push_back("a");
|
|
||||||
// v.push_back("b");
|
|
||||||
// return v;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// INSTANTIATE_TEST_CASE_P(CharSequence,
|
|
||||||
// StlStringTest,
|
|
||||||
// ValuesIn(GetParameterStrings()));
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// This will also instantiate tests from CharTest
|
|
||||||
// each with parameter values 'a' and 'b':
|
|
||||||
//
|
|
||||||
// ::std::list<char> GetParameterChars() {
|
|
||||||
// ::std::list<char> list;
|
|
||||||
// list.push_back('a');
|
|
||||||
// list.push_back('b');
|
|
||||||
// return list;
|
|
||||||
// }
|
|
||||||
// ::std::list<char> l = GetParameterChars();
|
|
||||||
// INSTANTIATE_TEST_CASE_P(CharSequence2,
|
|
||||||
// CharTest,
|
|
||||||
// ValuesIn(l.begin(), l.end()));
|
|
||||||
//
|
|
||||||
template <typename ForwardIterator>
|
|
||||||
internal::ParamGenerator<
|
|
||||||
typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>
|
|
||||||
ValuesIn(ForwardIterator begin, ForwardIterator end) {
|
|
||||||
typedef typename ::testing::internal::IteratorTraits<ForwardIterator>
|
|
||||||
::value_type ParamType;
|
|
||||||
return internal::ParamGenerator<ParamType>(
|
|
||||||
new internal::ValuesInIteratorRangeGenerator<ParamType>(begin, end));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, size_t N>
|
|
||||||
internal::ParamGenerator<T> ValuesIn(const T (&array)[N]) {
|
|
||||||
return ValuesIn(array, array + N);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Container>
|
|
||||||
internal::ParamGenerator<typename Container::value_type> ValuesIn(
|
|
||||||
const Container& container) {
|
|
||||||
return ValuesIn(container.begin(), container.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Values() allows generating tests from explicitly specified list of
|
|
||||||
// parameters.
|
|
||||||
//
|
|
||||||
// Synopsis:
|
|
||||||
// Values(T v1, T v2, ..., T vN)
|
|
||||||
// - returns a generator producing sequences with elements v1, v2, ..., vN.
|
|
||||||
//
|
|
||||||
// For example, this instantiates tests from test case BarTest each
|
|
||||||
// with values "one", "two", and "three":
|
|
||||||
//
|
|
||||||
// INSTANTIATE_TEST_CASE_P(NumSequence, BarTest, Values("one", "two", "three"));
|
|
||||||
//
|
|
||||||
// This instantiates tests from test case BazTest each with values 1, 2, 3.5.
|
|
||||||
// The exact type of values will depend on the type of parameter in BazTest.
|
|
||||||
//
|
|
||||||
// INSTANTIATE_TEST_CASE_P(FloatingNumbers, BazTest, Values(1, 2, 3.5));
|
|
||||||
//
|
|
||||||
// Currently, Values() supports from 1 to $n parameters.
|
|
||||||
//
|
|
||||||
$range i 1..n
|
|
||||||
$for i [[
|
|
||||||
$range j 1..i
|
|
||||||
|
|
||||||
template <$for j, [[typename T$j]]>
|
|
||||||
internal::ValueArray$i<$for j, [[T$j]]> Values($for j, [[T$j v$j]]) {
|
|
||||||
return internal::ValueArray$i<$for j, [[T$j]]>($for j, [[v$j]]);
|
|
||||||
}
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
// Bool() allows generating tests with parameters in a set of (false, true).
|
|
||||||
//
|
|
||||||
// Synopsis:
|
|
||||||
// Bool()
|
|
||||||
// - returns a generator producing sequences with elements {false, true}.
|
|
||||||
//
|
|
||||||
// It is useful when testing code that depends on Boolean flags. Combinations
|
|
||||||
// of multiple flags can be tested when several Bool()'s are combined using
|
|
||||||
// Combine() function.
|
|
||||||
//
|
|
||||||
// In the following example all tests in the test case FlagDependentTest
|
|
||||||
// will be instantiated twice with parameters false and true.
|
|
||||||
//
|
|
||||||
// class FlagDependentTest : public testing::TestWithParam<bool> {
|
|
||||||
// virtual void SetUp() {
|
|
||||||
// external_flag = GetParam();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// INSTANTIATE_TEST_CASE_P(BoolSequence, FlagDependentTest, Bool());
|
|
||||||
//
|
|
||||||
inline internal::ParamGenerator<bool> Bool() {
|
|
||||||
return Values(false, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
# if GTEST_HAS_COMBINE
|
|
||||||
// Combine() allows the user to combine two or more sequences to produce
|
|
||||||
// values of a Cartesian product of those sequences' elements.
|
|
||||||
//
|
|
||||||
// Synopsis:
|
|
||||||
// Combine(gen1, gen2, ..., genN)
|
|
||||||
// - returns a generator producing sequences with elements coming from
|
|
||||||
// the Cartesian product of elements from the sequences generated by
|
|
||||||
// gen1, gen2, ..., genN. The sequence elements will have a type of
|
|
||||||
// tuple<T1, T2, ..., TN> where T1, T2, ..., TN are the types
|
|
||||||
// of elements from sequences produces by gen1, gen2, ..., genN.
|
|
||||||
//
|
|
||||||
// Combine can have up to $maxtuple arguments. This number is currently limited
|
|
||||||
// by the maximum number of elements in the tuple implementation used by Google
|
|
||||||
// Test.
|
|
||||||
//
|
|
||||||
// Example:
|
|
||||||
//
|
|
||||||
// This will instantiate tests in test case AnimalTest each one with
|
|
||||||
// the parameter values tuple("cat", BLACK), tuple("cat", WHITE),
|
|
||||||
// tuple("dog", BLACK), and tuple("dog", WHITE):
|
|
||||||
//
|
|
||||||
// enum Color { BLACK, GRAY, WHITE };
|
|
||||||
// class AnimalTest
|
|
||||||
// : public testing::TestWithParam<tuple<const char*, Color> > {...};
|
|
||||||
//
|
|
||||||
// TEST_P(AnimalTest, AnimalLooksNice) {...}
|
|
||||||
//
|
|
||||||
// INSTANTIATE_TEST_CASE_P(AnimalVariations, AnimalTest,
|
|
||||||
// Combine(Values("cat", "dog"),
|
|
||||||
// Values(BLACK, WHITE)));
|
|
||||||
//
|
|
||||||
// This will instantiate tests in FlagDependentTest with all variations of two
|
|
||||||
// Boolean flags:
|
|
||||||
//
|
|
||||||
// class FlagDependentTest
|
|
||||||
// : public testing::TestWithParam<tuple<bool, bool> > {
|
|
||||||
// virtual void SetUp() {
|
|
||||||
// // Assigns external_flag_1 and external_flag_2 values from the tuple.
|
|
||||||
// tie(external_flag_1, external_flag_2) = GetParam();
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// TEST_P(FlagDependentTest, TestFeature1) {
|
|
||||||
// // Test your code using external_flag_1 and external_flag_2 here.
|
|
||||||
// }
|
|
||||||
// INSTANTIATE_TEST_CASE_P(TwoBoolSequence, FlagDependentTest,
|
|
||||||
// Combine(Bool(), Bool()));
|
|
||||||
//
|
|
||||||
$range i 2..maxtuple
|
|
||||||
$for i [[
|
|
||||||
$range j 1..i
|
|
||||||
|
|
||||||
template <$for j, [[typename Generator$j]]>
|
|
||||||
internal::CartesianProductHolder$i<$for j, [[Generator$j]]> Combine(
|
|
||||||
$for j, [[const Generator$j& g$j]]) {
|
|
||||||
return internal::CartesianProductHolder$i<$for j, [[Generator$j]]>(
|
|
||||||
$for j, [[g$j]]);
|
|
||||||
}
|
|
||||||
|
|
||||||
]]
|
|
||||||
# endif // GTEST_HAS_COMBINE
|
|
||||||
|
|
||||||
# define TEST_P(test_case_name, test_name) \
|
|
||||||
class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
|
|
||||||
: public test_case_name { \
|
|
||||||
public: \
|
|
||||||
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {} \
|
|
||||||
virtual void TestBody(); \
|
|
||||||
private: \
|
|
||||||
static int AddToRegistry() { \
|
|
||||||
::testing::UnitTest::GetInstance()->parameterized_test_registry(). \
|
|
||||||
GetTestCasePatternHolder<test_case_name>(\
|
|
||||||
#test_case_name, \
|
|
||||||
::testing::internal::CodeLocation(\
|
|
||||||
__FILE__, __LINE__))->AddTestPattern(\
|
|
||||||
GTEST_STRINGIFY_(test_case_name), \
|
|
||||||
GTEST_STRINGIFY_(test_name), \
|
|
||||||
new ::testing::internal::TestMetaFactory< \
|
|
||||||
GTEST_TEST_CLASS_NAME_(\
|
|
||||||
test_case_name, test_name)>()); \
|
|
||||||
return 0; \
|
|
||||||
} \
|
|
||||||
static int gtest_registering_dummy_ GTEST_ATTRIBUTE_UNUSED_; \
|
|
||||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(\
|
|
||||||
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)); \
|
|
||||||
}; \
|
|
||||||
int GTEST_TEST_CLASS_NAME_(test_case_name, \
|
|
||||||
test_name)::gtest_registering_dummy_ = \
|
|
||||||
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \
|
|
||||||
void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody()
|
|
||||||
|
|
||||||
// The optional last argument to INSTANTIATE_TEST_CASE_P allows the user
|
|
||||||
// to specify a function or functor that generates custom test name suffixes
|
|
||||||
// based on the test parameters. The function should accept one argument of
|
|
||||||
// type testing::TestParamInfo<class ParamType>, and return std::string.
|
|
||||||
//
|
|
||||||
// testing::PrintToStringParamName is a builtin test suffix generator that
|
|
||||||
// returns the value of testing::PrintToString(GetParam()).
|
|
||||||
//
|
|
||||||
// Note: test names must be non-empty, unique, and may only contain ASCII
|
|
||||||
// alphanumeric characters or underscore. Because PrintToString adds quotes
|
|
||||||
// to std::string and C strings, it won't work for these types.
|
|
||||||
|
|
||||||
# define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator, ...) \
|
|
||||||
static ::testing::internal::ParamGenerator<test_case_name::ParamType> \
|
|
||||||
gtest_##prefix##test_case_name##_EvalGenerator_() { return generator; } \
|
|
||||||
static ::std::string gtest_##prefix##test_case_name##_EvalGenerateName_( \
|
|
||||||
const ::testing::TestParamInfo<test_case_name::ParamType>& info) { \
|
|
||||||
return ::testing::internal::GetParamNameGen<test_case_name::ParamType> \
|
|
||||||
(__VA_ARGS__)(info); \
|
|
||||||
} \
|
|
||||||
static int gtest_##prefix##test_case_name##_dummy_ GTEST_ATTRIBUTE_UNUSED_ = \
|
|
||||||
::testing::UnitTest::GetInstance()->parameterized_test_registry(). \
|
|
||||||
GetTestCasePatternHolder<test_case_name>(\
|
|
||||||
#test_case_name, \
|
|
||||||
::testing::internal::CodeLocation(\
|
|
||||||
__FILE__, __LINE__))->AddTestCaseInstantiation(\
|
|
||||||
#prefix, \
|
|
||||||
>est_##prefix##test_case_name##_EvalGenerator_, \
|
|
||||||
>est_##prefix##test_case_name##_EvalGenerateName_, \
|
|
||||||
__FILE__, __LINE__)
|
|
||||||
|
|
||||||
} // namespace testing
|
|
||||||
|
|
||||||
#endif // GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,237 +0,0 @@
|
|||||||
// Copyright 2007, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
//
|
|
||||||
// Utilities for testing Google Test itself and code that uses Google Test
|
|
||||||
// (e.g. frameworks built on top of Google Test).
|
|
||||||
|
|
||||||
// GOOGLETEST_CM0004 DO NOT DELETE
|
|
||||||
|
|
||||||
#ifndef GTEST_INCLUDE_GTEST_GTEST_SPI_H_
|
|
||||||
#define GTEST_INCLUDE_GTEST_GTEST_SPI_H_
|
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
|
||||||
|
|
||||||
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
|
|
||||||
/* class A needs to have dll-interface to be used by clients of class B */)
|
|
||||||
|
|
||||||
namespace testing {
|
|
||||||
|
|
||||||
// This helper class can be used to mock out Google Test failure reporting
|
|
||||||
// so that we can test Google Test or code that builds on Google Test.
|
|
||||||
//
|
|
||||||
// An object of this class appends a TestPartResult object to the
|
|
||||||
// TestPartResultArray object given in the constructor whenever a Google Test
|
|
||||||
// failure is reported. It can either intercept only failures that are
|
|
||||||
// generated in the same thread that created this object or it can intercept
|
|
||||||
// all generated failures. The scope of this mock object can be controlled with
|
|
||||||
// the second argument to the two arguments constructor.
|
|
||||||
class GTEST_API_ ScopedFakeTestPartResultReporter
|
|
||||||
: public TestPartResultReporterInterface {
|
|
||||||
public:
|
|
||||||
// The two possible mocking modes of this object.
|
|
||||||
enum InterceptMode {
|
|
||||||
INTERCEPT_ONLY_CURRENT_THREAD, // Intercepts only thread local failures.
|
|
||||||
INTERCEPT_ALL_THREADS // Intercepts all failures.
|
|
||||||
};
|
|
||||||
|
|
||||||
// The c'tor sets this object as the test part result reporter used
|
|
||||||
// by Google Test. The 'result' parameter specifies where to report the
|
|
||||||
// results. This reporter will only catch failures generated in the current
|
|
||||||
// thread. DEPRECATED
|
|
||||||
explicit ScopedFakeTestPartResultReporter(TestPartResultArray* result);
|
|
||||||
|
|
||||||
// Same as above, but you can choose the interception scope of this object.
|
|
||||||
ScopedFakeTestPartResultReporter(InterceptMode intercept_mode,
|
|
||||||
TestPartResultArray* result);
|
|
||||||
|
|
||||||
// The d'tor restores the previous test part result reporter.
|
|
||||||
virtual ~ScopedFakeTestPartResultReporter();
|
|
||||||
|
|
||||||
// Appends the TestPartResult object to the TestPartResultArray
|
|
||||||
// received in the constructor.
|
|
||||||
//
|
|
||||||
// This method is from the TestPartResultReporterInterface
|
|
||||||
// interface.
|
|
||||||
virtual void ReportTestPartResult(const TestPartResult& result);
|
|
||||||
private:
|
|
||||||
void Init();
|
|
||||||
|
|
||||||
const InterceptMode intercept_mode_;
|
|
||||||
TestPartResultReporterInterface* old_reporter_;
|
|
||||||
TestPartResultArray* const result_;
|
|
||||||
|
|
||||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedFakeTestPartResultReporter);
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
// A helper class for implementing EXPECT_FATAL_FAILURE() and
|
|
||||||
// EXPECT_NONFATAL_FAILURE(). Its destructor verifies that the given
|
|
||||||
// TestPartResultArray contains exactly one failure that has the given
|
|
||||||
// type and contains the given substring. If that's not the case, a
|
|
||||||
// non-fatal failure will be generated.
|
|
||||||
class GTEST_API_ SingleFailureChecker {
|
|
||||||
public:
|
|
||||||
// The constructor remembers the arguments.
|
|
||||||
SingleFailureChecker(const TestPartResultArray* results,
|
|
||||||
TestPartResult::Type type, const std::string& substr);
|
|
||||||
~SingleFailureChecker();
|
|
||||||
private:
|
|
||||||
const TestPartResultArray* const results_;
|
|
||||||
const TestPartResult::Type type_;
|
|
||||||
const std::string substr_;
|
|
||||||
|
|
||||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(SingleFailureChecker);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
|
|
||||||
} // namespace testing
|
|
||||||
|
|
||||||
GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
|
|
||||||
|
|
||||||
// A set of macros for testing Google Test assertions or code that's expected
|
|
||||||
// to generate Google Test fatal failures. It verifies that the given
|
|
||||||
// statement will cause exactly one fatal Google Test failure with 'substr'
|
|
||||||
// being part of the failure message.
|
|
||||||
//
|
|
||||||
// There are two different versions of this macro. EXPECT_FATAL_FAILURE only
|
|
||||||
// affects and considers failures generated in the current thread and
|
|
||||||
// EXPECT_FATAL_FAILURE_ON_ALL_THREADS does the same but for all threads.
|
|
||||||
//
|
|
||||||
// The verification of the assertion is done correctly even when the statement
|
|
||||||
// throws an exception or aborts the current function.
|
|
||||||
//
|
|
||||||
// Known restrictions:
|
|
||||||
// - 'statement' cannot reference local non-static variables or
|
|
||||||
// non-static members of the current object.
|
|
||||||
// - 'statement' cannot return a value.
|
|
||||||
// - You cannot stream a failure message to this macro.
|
|
||||||
//
|
|
||||||
// Note that even though the implementations of the following two
|
|
||||||
// macros are much alike, we cannot refactor them to use a common
|
|
||||||
// helper macro, due to some peculiarity in how the preprocessor
|
|
||||||
// works. The AcceptsMacroThatExpandsToUnprotectedComma test in
|
|
||||||
// gtest_unittest.cc will fail to compile if we do that.
|
|
||||||
#define EXPECT_FATAL_FAILURE(statement, substr) \
|
|
||||||
do { \
|
|
||||||
class GTestExpectFatalFailureHelper {\
|
|
||||||
public:\
|
|
||||||
static void Execute() { statement; }\
|
|
||||||
};\
|
|
||||||
::testing::TestPartResultArray gtest_failures;\
|
|
||||||
::testing::internal::SingleFailureChecker gtest_checker(\
|
|
||||||
>est_failures, ::testing::TestPartResult::kFatalFailure, (substr));\
|
|
||||||
{\
|
|
||||||
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
|
|
||||||
::testing::ScopedFakeTestPartResultReporter:: \
|
|
||||||
INTERCEPT_ONLY_CURRENT_THREAD, >est_failures);\
|
|
||||||
GTestExpectFatalFailureHelper::Execute();\
|
|
||||||
}\
|
|
||||||
} while (::testing::internal::AlwaysFalse())
|
|
||||||
|
|
||||||
#define EXPECT_FATAL_FAILURE_ON_ALL_THREADS(statement, substr) \
|
|
||||||
do { \
|
|
||||||
class GTestExpectFatalFailureHelper {\
|
|
||||||
public:\
|
|
||||||
static void Execute() { statement; }\
|
|
||||||
};\
|
|
||||||
::testing::TestPartResultArray gtest_failures;\
|
|
||||||
::testing::internal::SingleFailureChecker gtest_checker(\
|
|
||||||
>est_failures, ::testing::TestPartResult::kFatalFailure, (substr));\
|
|
||||||
{\
|
|
||||||
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
|
|
||||||
::testing::ScopedFakeTestPartResultReporter:: \
|
|
||||||
INTERCEPT_ALL_THREADS, >est_failures);\
|
|
||||||
GTestExpectFatalFailureHelper::Execute();\
|
|
||||||
}\
|
|
||||||
} while (::testing::internal::AlwaysFalse())
|
|
||||||
|
|
||||||
// A macro for testing Google Test assertions or code that's expected to
|
|
||||||
// generate Google Test non-fatal failures. It asserts that the given
|
|
||||||
// statement will cause exactly one non-fatal Google Test failure with 'substr'
|
|
||||||
// being part of the failure message.
|
|
||||||
//
|
|
||||||
// There are two different versions of this macro. EXPECT_NONFATAL_FAILURE only
|
|
||||||
// affects and considers failures generated in the current thread and
|
|
||||||
// EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS does the same but for all threads.
|
|
||||||
//
|
|
||||||
// 'statement' is allowed to reference local variables and members of
|
|
||||||
// the current object.
|
|
||||||
//
|
|
||||||
// The verification of the assertion is done correctly even when the statement
|
|
||||||
// throws an exception or aborts the current function.
|
|
||||||
//
|
|
||||||
// Known restrictions:
|
|
||||||
// - You cannot stream a failure message to this macro.
|
|
||||||
//
|
|
||||||
// Note that even though the implementations of the following two
|
|
||||||
// macros are much alike, we cannot refactor them to use a common
|
|
||||||
// helper macro, due to some peculiarity in how the preprocessor
|
|
||||||
// works. If we do that, the code won't compile when the user gives
|
|
||||||
// EXPECT_NONFATAL_FAILURE() a statement that contains a macro that
|
|
||||||
// expands to code containing an unprotected comma. The
|
|
||||||
// AcceptsMacroThatExpandsToUnprotectedComma test in gtest_unittest.cc
|
|
||||||
// catches that.
|
|
||||||
//
|
|
||||||
// For the same reason, we have to write
|
|
||||||
// if (::testing::internal::AlwaysTrue()) { statement; }
|
|
||||||
// instead of
|
|
||||||
// GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)
|
|
||||||
// to avoid an MSVC warning on unreachable code.
|
|
||||||
#define EXPECT_NONFATAL_FAILURE(statement, substr) \
|
|
||||||
do {\
|
|
||||||
::testing::TestPartResultArray gtest_failures;\
|
|
||||||
::testing::internal::SingleFailureChecker gtest_checker(\
|
|
||||||
>est_failures, ::testing::TestPartResult::kNonFatalFailure, \
|
|
||||||
(substr));\
|
|
||||||
{\
|
|
||||||
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
|
|
||||||
::testing::ScopedFakeTestPartResultReporter:: \
|
|
||||||
INTERCEPT_ONLY_CURRENT_THREAD, >est_failures);\
|
|
||||||
if (::testing::internal::AlwaysTrue()) { statement; }\
|
|
||||||
}\
|
|
||||||
} while (::testing::internal::AlwaysFalse())
|
|
||||||
|
|
||||||
#define EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(statement, substr) \
|
|
||||||
do {\
|
|
||||||
::testing::TestPartResultArray gtest_failures;\
|
|
||||||
::testing::internal::SingleFailureChecker gtest_checker(\
|
|
||||||
>est_failures, ::testing::TestPartResult::kNonFatalFailure, \
|
|
||||||
(substr));\
|
|
||||||
{\
|
|
||||||
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
|
|
||||||
::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS, \
|
|
||||||
>est_failures);\
|
|
||||||
if (::testing::internal::AlwaysTrue()) { statement; }\
|
|
||||||
}\
|
|
||||||
} while (::testing::internal::AlwaysFalse())
|
|
||||||
|
|
||||||
#endif // GTEST_INCLUDE_GTEST_GTEST_SPI_H_
|
|
||||||
@@ -1,183 +0,0 @@
|
|||||||
// Copyright 2008, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
//
|
|
||||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
|
||||||
|
|
||||||
#ifndef GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
|
|
||||||
#define GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
|
|
||||||
|
|
||||||
#include <iosfwd>
|
|
||||||
#include <vector>
|
|
||||||
#include "gtest/internal/gtest-internal.h"
|
|
||||||
#include "gtest/internal/gtest-string.h"
|
|
||||||
|
|
||||||
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
|
|
||||||
/* class A needs to have dll-interface to be used by clients of class B */)
|
|
||||||
|
|
||||||
namespace testing {
|
|
||||||
|
|
||||||
// A copyable object representing the result of a test part (i.e. an
|
|
||||||
// assertion or an explicit FAIL(), ADD_FAILURE(), or SUCCESS()).
|
|
||||||
//
|
|
||||||
// Don't inherit from TestPartResult as its destructor is not virtual.
|
|
||||||
class GTEST_API_ TestPartResult {
|
|
||||||
public:
|
|
||||||
// The possible outcomes of a test part (i.e. an assertion or an
|
|
||||||
// explicit SUCCEED(), FAIL(), or ADD_FAILURE()).
|
|
||||||
enum Type {
|
|
||||||
kSuccess, // Succeeded.
|
|
||||||
kNonFatalFailure, // Failed but the test can continue.
|
|
||||||
kFatalFailure // Failed and the test should be terminated.
|
|
||||||
};
|
|
||||||
|
|
||||||
// C'tor. TestPartResult does NOT have a default constructor.
|
|
||||||
// Always use this constructor (with parameters) to create a
|
|
||||||
// TestPartResult object.
|
|
||||||
TestPartResult(Type a_type,
|
|
||||||
const char* a_file_name,
|
|
||||||
int a_line_number,
|
|
||||||
const char* a_message)
|
|
||||||
: type_(a_type),
|
|
||||||
file_name_(a_file_name == NULL ? "" : a_file_name),
|
|
||||||
line_number_(a_line_number),
|
|
||||||
summary_(ExtractSummary(a_message)),
|
|
||||||
message_(a_message) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Gets the outcome of the test part.
|
|
||||||
Type type() const { return type_; }
|
|
||||||
|
|
||||||
// Gets the name of the source file where the test part took place, or
|
|
||||||
// NULL if it's unknown.
|
|
||||||
const char* file_name() const {
|
|
||||||
return file_name_.empty() ? NULL : file_name_.c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Gets the line in the source file where the test part took place,
|
|
||||||
// or -1 if it's unknown.
|
|
||||||
int line_number() const { return line_number_; }
|
|
||||||
|
|
||||||
// Gets the summary of the failure message.
|
|
||||||
const char* summary() const { return summary_.c_str(); }
|
|
||||||
|
|
||||||
// Gets the message associated with the test part.
|
|
||||||
const char* message() const { return message_.c_str(); }
|
|
||||||
|
|
||||||
// Returns true iff the test part passed.
|
|
||||||
bool passed() const { return type_ == kSuccess; }
|
|
||||||
|
|
||||||
// Returns true iff the test part failed.
|
|
||||||
bool failed() const { return type_ != kSuccess; }
|
|
||||||
|
|
||||||
// Returns true iff the test part non-fatally failed.
|
|
||||||
bool nonfatally_failed() const { return type_ == kNonFatalFailure; }
|
|
||||||
|
|
||||||
// Returns true iff the test part fatally failed.
|
|
||||||
bool fatally_failed() const { return type_ == kFatalFailure; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
Type type_;
|
|
||||||
|
|
||||||
// Gets the summary of the failure message by omitting the stack
|
|
||||||
// trace in it.
|
|
||||||
static std::string ExtractSummary(const char* message);
|
|
||||||
|
|
||||||
// The name of the source file where the test part took place, or
|
|
||||||
// "" if the source file is unknown.
|
|
||||||
std::string file_name_;
|
|
||||||
// The line in the source file where the test part took place, or -1
|
|
||||||
// if the line number is unknown.
|
|
||||||
int line_number_;
|
|
||||||
std::string summary_; // The test failure summary.
|
|
||||||
std::string message_; // The test failure message.
|
|
||||||
};
|
|
||||||
|
|
||||||
// Prints a TestPartResult object.
|
|
||||||
std::ostream& operator<<(std::ostream& os, const TestPartResult& result);
|
|
||||||
|
|
||||||
// An array of TestPartResult objects.
|
|
||||||
//
|
|
||||||
// Don't inherit from TestPartResultArray as its destructor is not
|
|
||||||
// virtual.
|
|
||||||
class GTEST_API_ TestPartResultArray {
|
|
||||||
public:
|
|
||||||
TestPartResultArray() {}
|
|
||||||
|
|
||||||
// Appends the given TestPartResult to the array.
|
|
||||||
void Append(const TestPartResult& result);
|
|
||||||
|
|
||||||
// Returns the TestPartResult at the given index (0-based).
|
|
||||||
const TestPartResult& GetTestPartResult(int index) const;
|
|
||||||
|
|
||||||
// Returns the number of TestPartResult objects in the array.
|
|
||||||
int size() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::vector<TestPartResult> array_;
|
|
||||||
|
|
||||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestPartResultArray);
|
|
||||||
};
|
|
||||||
|
|
||||||
// This interface knows how to report a test part result.
|
|
||||||
class GTEST_API_ TestPartResultReporterInterface {
|
|
||||||
public:
|
|
||||||
virtual ~TestPartResultReporterInterface() {}
|
|
||||||
|
|
||||||
virtual void ReportTestPartResult(const TestPartResult& result) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
// This helper class is used by {ASSERT|EXPECT}_NO_FATAL_FAILURE to check if a
|
|
||||||
// statement generates new fatal failures. To do so it registers itself as the
|
|
||||||
// current test part result reporter. Besides checking if fatal failures were
|
|
||||||
// reported, it only delegates the reporting to the former result reporter.
|
|
||||||
// The original result reporter is restored in the destructor.
|
|
||||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
|
|
||||||
class GTEST_API_ HasNewFatalFailureHelper
|
|
||||||
: public TestPartResultReporterInterface {
|
|
||||||
public:
|
|
||||||
HasNewFatalFailureHelper();
|
|
||||||
virtual ~HasNewFatalFailureHelper();
|
|
||||||
virtual void ReportTestPartResult(const TestPartResult& result);
|
|
||||||
bool has_new_fatal_failure() const { return has_new_fatal_failure_; }
|
|
||||||
private:
|
|
||||||
bool has_new_fatal_failure_;
|
|
||||||
TestPartResultReporterInterface* original_reporter_;
|
|
||||||
|
|
||||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(HasNewFatalFailureHelper);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
|
|
||||||
} // namespace testing
|
|
||||||
|
|
||||||
GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
|
|
||||||
|
|
||||||
#endif // GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
|
|
||||||
@@ -1,306 +0,0 @@
|
|||||||
// Copyright 2008 Google Inc.
|
|
||||||
// All Rights Reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
|
||||||
|
|
||||||
#ifndef GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
|
|
||||||
#define GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
|
|
||||||
|
|
||||||
// This header implements typed tests and type-parameterized tests.
|
|
||||||
|
|
||||||
// Typed (aka type-driven) tests repeat the same test for types in a
|
|
||||||
// list. You must know which types you want to test with when writing
|
|
||||||
// typed tests. Here's how you do it:
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
// First, define a fixture class template. It should be parameterized
|
|
||||||
// by a type. Remember to derive it from testing::Test.
|
|
||||||
template <typename T>
|
|
||||||
class FooTest : public testing::Test {
|
|
||||||
public:
|
|
||||||
...
|
|
||||||
typedef std::list<T> List;
|
|
||||||
static T shared_;
|
|
||||||
T value_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Next, associate a list of types with the test case, which will be
|
|
||||||
// repeated for each type in the list. The typedef is necessary for
|
|
||||||
// the macro to parse correctly.
|
|
||||||
typedef testing::Types<char, int, unsigned int> MyTypes;
|
|
||||||
TYPED_TEST_CASE(FooTest, MyTypes);
|
|
||||||
|
|
||||||
// If the type list contains only one type, you can write that type
|
|
||||||
// directly without Types<...>:
|
|
||||||
// TYPED_TEST_CASE(FooTest, int);
|
|
||||||
|
|
||||||
// Then, use TYPED_TEST() instead of TEST_F() to define as many typed
|
|
||||||
// tests for this test case as you want.
|
|
||||||
TYPED_TEST(FooTest, DoesBlah) {
|
|
||||||
// Inside a test, refer to TypeParam to get the type parameter.
|
|
||||||
// Since we are inside a derived class template, C++ requires use to
|
|
||||||
// visit the members of FooTest via 'this'.
|
|
||||||
TypeParam n = this->value_;
|
|
||||||
|
|
||||||
// To visit static members of the fixture, add the TestFixture::
|
|
||||||
// prefix.
|
|
||||||
n += TestFixture::shared_;
|
|
||||||
|
|
||||||
// To refer to typedefs in the fixture, add the "typename
|
|
||||||
// TestFixture::" prefix.
|
|
||||||
typename TestFixture::List values;
|
|
||||||
values.push_back(n);
|
|
||||||
...
|
|
||||||
}
|
|
||||||
|
|
||||||
TYPED_TEST(FooTest, HasPropertyA) { ... }
|
|
||||||
|
|
||||||
// TYPED_TEST_CASE takes an optional third argument which allows to specify a
|
|
||||||
// class that generates custom test name suffixes based on the type. This should
|
|
||||||
// be a class which has a static template function GetName(int index) returning
|
|
||||||
// a string for each type. The provided integer index equals the index of the
|
|
||||||
// type in the provided type list. In many cases the index can be ignored.
|
|
||||||
//
|
|
||||||
// For example:
|
|
||||||
// class MyTypeNames {
|
|
||||||
// public:
|
|
||||||
// template <typename T>
|
|
||||||
// static std::string GetName(int) {
|
|
||||||
// if (std::is_same<T, char>()) return "char";
|
|
||||||
// if (std::is_same<T, int>()) return "int";
|
|
||||||
// if (std::is_same<T, unsigned int>()) return "unsignedInt";
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
// TYPED_TEST_CASE(FooTest, MyTypes, MyTypeNames);
|
|
||||||
|
|
||||||
#endif // 0
|
|
||||||
|
|
||||||
// Type-parameterized tests are abstract test patterns parameterized
|
|
||||||
// by a type. Compared with typed tests, type-parameterized tests
|
|
||||||
// allow you to define the test pattern without knowing what the type
|
|
||||||
// parameters are. The defined pattern can be instantiated with
|
|
||||||
// different types any number of times, in any number of translation
|
|
||||||
// units.
|
|
||||||
//
|
|
||||||
// If you are designing an interface or concept, you can define a
|
|
||||||
// suite of type-parameterized tests to verify properties that any
|
|
||||||
// valid implementation of the interface/concept should have. Then,
|
|
||||||
// each implementation can easily instantiate the test suite to verify
|
|
||||||
// that it conforms to the requirements, without having to write
|
|
||||||
// similar tests repeatedly. Here's an example:
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
// First, define a fixture class template. It should be parameterized
|
|
||||||
// by a type. Remember to derive it from testing::Test.
|
|
||||||
template <typename T>
|
|
||||||
class FooTest : public testing::Test {
|
|
||||||
...
|
|
||||||
};
|
|
||||||
|
|
||||||
// Next, declare that you will define a type-parameterized test case
|
|
||||||
// (the _P suffix is for "parameterized" or "pattern", whichever you
|
|
||||||
// prefer):
|
|
||||||
TYPED_TEST_CASE_P(FooTest);
|
|
||||||
|
|
||||||
// Then, use TYPED_TEST_P() to define as many type-parameterized tests
|
|
||||||
// for this type-parameterized test case as you want.
|
|
||||||
TYPED_TEST_P(FooTest, DoesBlah) {
|
|
||||||
// Inside a test, refer to TypeParam to get the type parameter.
|
|
||||||
TypeParam n = 0;
|
|
||||||
...
|
|
||||||
}
|
|
||||||
|
|
||||||
TYPED_TEST_P(FooTest, HasPropertyA) { ... }
|
|
||||||
|
|
||||||
// Now the tricky part: you need to register all test patterns before
|
|
||||||
// you can instantiate them. The first argument of the macro is the
|
|
||||||
// test case name; the rest are the names of the tests in this test
|
|
||||||
// case.
|
|
||||||
REGISTER_TYPED_TEST_CASE_P(FooTest,
|
|
||||||
DoesBlah, HasPropertyA);
|
|
||||||
|
|
||||||
// Finally, you are free to instantiate the pattern with the types you
|
|
||||||
// want. If you put the above code in a header file, you can #include
|
|
||||||
// it in multiple C++ source files and instantiate it multiple times.
|
|
||||||
//
|
|
||||||
// To distinguish different instances of the pattern, the first
|
|
||||||
// argument to the INSTANTIATE_* macro is a prefix that will be added
|
|
||||||
// to the actual test case name. Remember to pick unique prefixes for
|
|
||||||
// different instances.
|
|
||||||
typedef testing::Types<char, int, unsigned int> MyTypes;
|
|
||||||
INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, MyTypes);
|
|
||||||
|
|
||||||
// If the type list contains only one type, you can write that type
|
|
||||||
// directly without Types<...>:
|
|
||||||
// INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, int);
|
|
||||||
//
|
|
||||||
// Similar to the optional argument of TYPED_TEST_CASE above,
|
|
||||||
// INSTANTIATE_TEST_CASE_P takes an optional fourth argument which allows to
|
|
||||||
// generate custom names.
|
|
||||||
// INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, MyTypes, MyTypeNames);
|
|
||||||
|
|
||||||
#endif // 0
|
|
||||||
|
|
||||||
#include "gtest/internal/gtest-port.h"
|
|
||||||
#include "gtest/internal/gtest-type-util.h"
|
|
||||||
|
|
||||||
// Implements typed tests.
|
|
||||||
|
|
||||||
#if GTEST_HAS_TYPED_TEST
|
|
||||||
|
|
||||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
|
|
||||||
//
|
|
||||||
// Expands to the name of the typedef for the type parameters of the
|
|
||||||
// given test case.
|
|
||||||
# define GTEST_TYPE_PARAMS_(TestCaseName) gtest_type_params_##TestCaseName##_
|
|
||||||
|
|
||||||
// Expands to the name of the typedef for the NameGenerator, responsible for
|
|
||||||
// creating the suffixes of the name.
|
|
||||||
#define GTEST_NAME_GENERATOR_(TestCaseName) \
|
|
||||||
gtest_type_params_##TestCaseName##_NameGenerator
|
|
||||||
|
|
||||||
// The 'Types' template argument below must have spaces around it
|
|
||||||
// since some compilers may choke on '>>' when passing a template
|
|
||||||
// instance (e.g. Types<int>)
|
|
||||||
# define TYPED_TEST_CASE(CaseName, Types, ...) \
|
|
||||||
typedef ::testing::internal::TypeList< Types >::type GTEST_TYPE_PARAMS_( \
|
|
||||||
CaseName); \
|
|
||||||
typedef ::testing::internal::NameGeneratorSelector<__VA_ARGS__>::type \
|
|
||||||
GTEST_NAME_GENERATOR_(CaseName)
|
|
||||||
|
|
||||||
# define TYPED_TEST(CaseName, TestName) \
|
|
||||||
template <typename gtest_TypeParam_> \
|
|
||||||
class GTEST_TEST_CLASS_NAME_(CaseName, TestName) \
|
|
||||||
: public CaseName<gtest_TypeParam_> { \
|
|
||||||
private: \
|
|
||||||
typedef CaseName<gtest_TypeParam_> TestFixture; \
|
|
||||||
typedef gtest_TypeParam_ TypeParam; \
|
|
||||||
virtual void TestBody(); \
|
|
||||||
}; \
|
|
||||||
static bool gtest_##CaseName##_##TestName##_registered_ \
|
|
||||||
GTEST_ATTRIBUTE_UNUSED_ = \
|
|
||||||
::testing::internal::TypeParameterizedTest< \
|
|
||||||
CaseName, \
|
|
||||||
::testing::internal::TemplateSel<GTEST_TEST_CLASS_NAME_(CaseName, \
|
|
||||||
TestName)>, \
|
|
||||||
GTEST_TYPE_PARAMS_( \
|
|
||||||
CaseName)>::Register("", \
|
|
||||||
::testing::internal::CodeLocation( \
|
|
||||||
__FILE__, __LINE__), \
|
|
||||||
#CaseName, #TestName, 0, \
|
|
||||||
::testing::internal::GenerateNames< \
|
|
||||||
GTEST_NAME_GENERATOR_(CaseName), \
|
|
||||||
GTEST_TYPE_PARAMS_(CaseName)>()); \
|
|
||||||
template <typename gtest_TypeParam_> \
|
|
||||||
void GTEST_TEST_CLASS_NAME_(CaseName, \
|
|
||||||
TestName)<gtest_TypeParam_>::TestBody()
|
|
||||||
|
|
||||||
#endif // GTEST_HAS_TYPED_TEST
|
|
||||||
|
|
||||||
// Implements type-parameterized tests.
|
|
||||||
|
|
||||||
#if GTEST_HAS_TYPED_TEST_P
|
|
||||||
|
|
||||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
|
|
||||||
//
|
|
||||||
// Expands to the namespace name that the type-parameterized tests for
|
|
||||||
// the given type-parameterized test case are defined in. The exact
|
|
||||||
// name of the namespace is subject to change without notice.
|
|
||||||
# define GTEST_CASE_NAMESPACE_(TestCaseName) \
|
|
||||||
gtest_case_##TestCaseName##_
|
|
||||||
|
|
||||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
|
|
||||||
//
|
|
||||||
// Expands to the name of the variable used to remember the names of
|
|
||||||
// the defined tests in the given test case.
|
|
||||||
# define GTEST_TYPED_TEST_CASE_P_STATE_(TestCaseName) \
|
|
||||||
gtest_typed_test_case_p_state_##TestCaseName##_
|
|
||||||
|
|
||||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE DIRECTLY.
|
|
||||||
//
|
|
||||||
// Expands to the name of the variable used to remember the names of
|
|
||||||
// the registered tests in the given test case.
|
|
||||||
# define GTEST_REGISTERED_TEST_NAMES_(TestCaseName) \
|
|
||||||
gtest_registered_test_names_##TestCaseName##_
|
|
||||||
|
|
||||||
// The variables defined in the type-parameterized test macros are
|
|
||||||
// static as typically these macros are used in a .h file that can be
|
|
||||||
// #included in multiple translation units linked together.
|
|
||||||
# define TYPED_TEST_CASE_P(CaseName) \
|
|
||||||
static ::testing::internal::TypedTestCasePState \
|
|
||||||
GTEST_TYPED_TEST_CASE_P_STATE_(CaseName)
|
|
||||||
|
|
||||||
# define TYPED_TEST_P(CaseName, TestName) \
|
|
||||||
namespace GTEST_CASE_NAMESPACE_(CaseName) { \
|
|
||||||
template <typename gtest_TypeParam_> \
|
|
||||||
class TestName : public CaseName<gtest_TypeParam_> { \
|
|
||||||
private: \
|
|
||||||
typedef CaseName<gtest_TypeParam_> TestFixture; \
|
|
||||||
typedef gtest_TypeParam_ TypeParam; \
|
|
||||||
virtual void TestBody(); \
|
|
||||||
}; \
|
|
||||||
static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \
|
|
||||||
GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).AddTestName(\
|
|
||||||
__FILE__, __LINE__, #CaseName, #TestName); \
|
|
||||||
} \
|
|
||||||
template <typename gtest_TypeParam_> \
|
|
||||||
void GTEST_CASE_NAMESPACE_(CaseName)::TestName<gtest_TypeParam_>::TestBody()
|
|
||||||
|
|
||||||
# define REGISTER_TYPED_TEST_CASE_P(CaseName, ...) \
|
|
||||||
namespace GTEST_CASE_NAMESPACE_(CaseName) { \
|
|
||||||
typedef ::testing::internal::Templates<__VA_ARGS__>::type gtest_AllTests_; \
|
|
||||||
} \
|
|
||||||
static const char* const GTEST_REGISTERED_TEST_NAMES_(CaseName) \
|
|
||||||
GTEST_ATTRIBUTE_UNUSED_ = \
|
|
||||||
GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).VerifyRegisteredTestNames( \
|
|
||||||
__FILE__, __LINE__, #__VA_ARGS__)
|
|
||||||
|
|
||||||
// The 'Types' template argument below must have spaces around it
|
|
||||||
// since some compilers may choke on '>>' when passing a template
|
|
||||||
// instance (e.g. Types<int>)
|
|
||||||
# define INSTANTIATE_TYPED_TEST_CASE_P(Prefix, CaseName, Types, ...) \
|
|
||||||
static bool gtest_##Prefix##_##CaseName GTEST_ATTRIBUTE_UNUSED_ = \
|
|
||||||
::testing::internal::TypeParameterizedTestCase< \
|
|
||||||
CaseName, GTEST_CASE_NAMESPACE_(CaseName)::gtest_AllTests_, \
|
|
||||||
::testing::internal::TypeList< Types >::type>:: \
|
|
||||||
Register(#Prefix, \
|
|
||||||
::testing::internal::CodeLocation(__FILE__, __LINE__), \
|
|
||||||
>EST_TYPED_TEST_CASE_P_STATE_(CaseName), #CaseName, \
|
|
||||||
GTEST_REGISTERED_TEST_NAMES_(CaseName), \
|
|
||||||
::testing::internal::GenerateNames< \
|
|
||||||
::testing::internal::NameGeneratorSelector< \
|
|
||||||
__VA_ARGS__>::type, \
|
|
||||||
::testing::internal::TypeList< Types >::type>())
|
|
||||||
|
|
||||||
#endif // GTEST_HAS_TYPED_TEST_P
|
|
||||||
|
|
||||||
#endif // GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,359 +0,0 @@
|
|||||||
// Copyright 2006, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
// This file is AUTOMATICALLY GENERATED on 01/02/2018 by command
|
|
||||||
// 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND!
|
|
||||||
//
|
|
||||||
// Implements a family of generic predicate assertion macros.
|
|
||||||
|
|
||||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
|
||||||
|
|
||||||
#ifndef GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
|
|
||||||
#define GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
|
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
|
||||||
|
|
||||||
namespace testing {
|
|
||||||
|
|
||||||
// This header implements a family of generic predicate assertion
|
|
||||||
// macros:
|
|
||||||
//
|
|
||||||
// ASSERT_PRED_FORMAT1(pred_format, v1)
|
|
||||||
// ASSERT_PRED_FORMAT2(pred_format, v1, v2)
|
|
||||||
// ...
|
|
||||||
//
|
|
||||||
// where pred_format is a function or functor that takes n (in the
|
|
||||||
// case of ASSERT_PRED_FORMATn) values and their source expression
|
|
||||||
// text, and returns a testing::AssertionResult. See the definition
|
|
||||||
// of ASSERT_EQ in gtest.h for an example.
|
|
||||||
//
|
|
||||||
// If you don't care about formatting, you can use the more
|
|
||||||
// restrictive version:
|
|
||||||
//
|
|
||||||
// ASSERT_PRED1(pred, v1)
|
|
||||||
// ASSERT_PRED2(pred, v1, v2)
|
|
||||||
// ...
|
|
||||||
//
|
|
||||||
// where pred is an n-ary function or functor that returns bool,
|
|
||||||
// and the values v1, v2, ..., must support the << operator for
|
|
||||||
// streaming to std::ostream.
|
|
||||||
//
|
|
||||||
// We also define the EXPECT_* variations.
|
|
||||||
//
|
|
||||||
// For now we only support predicates whose arity is at most 5.
|
|
||||||
|
|
||||||
// GTEST_ASSERT_ is the basic statement to which all of the assertions
|
|
||||||
// in this file reduce. Don't use this in your code.
|
|
||||||
|
|
||||||
#define GTEST_ASSERT_(expression, on_failure) \
|
|
||||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
|
||||||
if (const ::testing::AssertionResult gtest_ar = (expression)) \
|
|
||||||
; \
|
|
||||||
else \
|
|
||||||
on_failure(gtest_ar.failure_message())
|
|
||||||
|
|
||||||
|
|
||||||
// Helper function for implementing {EXPECT|ASSERT}_PRED1. Don't use
|
|
||||||
// this in your code.
|
|
||||||
template <typename Pred,
|
|
||||||
typename T1>
|
|
||||||
AssertionResult AssertPred1Helper(const char* pred_text,
|
|
||||||
const char* e1,
|
|
||||||
Pred pred,
|
|
||||||
const T1& v1) {
|
|
||||||
if (pred(v1)) return AssertionSuccess();
|
|
||||||
|
|
||||||
return AssertionFailure() << pred_text << "("
|
|
||||||
<< e1 << ") evaluates to false, where"
|
|
||||||
<< "\n" << e1 << " evaluates to " << v1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT1.
|
|
||||||
// Don't use this in your code.
|
|
||||||
#define GTEST_PRED_FORMAT1_(pred_format, v1, on_failure)\
|
|
||||||
GTEST_ASSERT_(pred_format(#v1, v1), \
|
|
||||||
on_failure)
|
|
||||||
|
|
||||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED1. Don't use
|
|
||||||
// this in your code.
|
|
||||||
#define GTEST_PRED1_(pred, v1, on_failure)\
|
|
||||||
GTEST_ASSERT_(::testing::AssertPred1Helper(#pred, \
|
|
||||||
#v1, \
|
|
||||||
pred, \
|
|
||||||
v1), on_failure)
|
|
||||||
|
|
||||||
// Unary predicate assertion macros.
|
|
||||||
#define EXPECT_PRED_FORMAT1(pred_format, v1) \
|
|
||||||
GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_NONFATAL_FAILURE_)
|
|
||||||
#define EXPECT_PRED1(pred, v1) \
|
|
||||||
GTEST_PRED1_(pred, v1, GTEST_NONFATAL_FAILURE_)
|
|
||||||
#define ASSERT_PRED_FORMAT1(pred_format, v1) \
|
|
||||||
GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_FATAL_FAILURE_)
|
|
||||||
#define ASSERT_PRED1(pred, v1) \
|
|
||||||
GTEST_PRED1_(pred, v1, GTEST_FATAL_FAILURE_)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Helper function for implementing {EXPECT|ASSERT}_PRED2. Don't use
|
|
||||||
// this in your code.
|
|
||||||
template <typename Pred,
|
|
||||||
typename T1,
|
|
||||||
typename T2>
|
|
||||||
AssertionResult AssertPred2Helper(const char* pred_text,
|
|
||||||
const char* e1,
|
|
||||||
const char* e2,
|
|
||||||
Pred pred,
|
|
||||||
const T1& v1,
|
|
||||||
const T2& v2) {
|
|
||||||
if (pred(v1, v2)) return AssertionSuccess();
|
|
||||||
|
|
||||||
return AssertionFailure() << pred_text << "("
|
|
||||||
<< e1 << ", "
|
|
||||||
<< e2 << ") evaluates to false, where"
|
|
||||||
<< "\n" << e1 << " evaluates to " << v1
|
|
||||||
<< "\n" << e2 << " evaluates to " << v2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT2.
|
|
||||||
// Don't use this in your code.
|
|
||||||
#define GTEST_PRED_FORMAT2_(pred_format, v1, v2, on_failure)\
|
|
||||||
GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), \
|
|
||||||
on_failure)
|
|
||||||
|
|
||||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED2. Don't use
|
|
||||||
// this in your code.
|
|
||||||
#define GTEST_PRED2_(pred, v1, v2, on_failure)\
|
|
||||||
GTEST_ASSERT_(::testing::AssertPred2Helper(#pred, \
|
|
||||||
#v1, \
|
|
||||||
#v2, \
|
|
||||||
pred, \
|
|
||||||
v1, \
|
|
||||||
v2), on_failure)
|
|
||||||
|
|
||||||
// Binary predicate assertion macros.
|
|
||||||
#define EXPECT_PRED_FORMAT2(pred_format, v1, v2) \
|
|
||||||
GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
|
|
||||||
#define EXPECT_PRED2(pred, v1, v2) \
|
|
||||||
GTEST_PRED2_(pred, v1, v2, GTEST_NONFATAL_FAILURE_)
|
|
||||||
#define ASSERT_PRED_FORMAT2(pred_format, v1, v2) \
|
|
||||||
GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)
|
|
||||||
#define ASSERT_PRED2(pred, v1, v2) \
|
|
||||||
GTEST_PRED2_(pred, v1, v2, GTEST_FATAL_FAILURE_)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Helper function for implementing {EXPECT|ASSERT}_PRED3. Don't use
|
|
||||||
// this in your code.
|
|
||||||
template <typename Pred,
|
|
||||||
typename T1,
|
|
||||||
typename T2,
|
|
||||||
typename T3>
|
|
||||||
AssertionResult AssertPred3Helper(const char* pred_text,
|
|
||||||
const char* e1,
|
|
||||||
const char* e2,
|
|
||||||
const char* e3,
|
|
||||||
Pred pred,
|
|
||||||
const T1& v1,
|
|
||||||
const T2& v2,
|
|
||||||
const T3& v3) {
|
|
||||||
if (pred(v1, v2, v3)) return AssertionSuccess();
|
|
||||||
|
|
||||||
return AssertionFailure() << pred_text << "("
|
|
||||||
<< e1 << ", "
|
|
||||||
<< e2 << ", "
|
|
||||||
<< e3 << ") evaluates to false, where"
|
|
||||||
<< "\n" << e1 << " evaluates to " << v1
|
|
||||||
<< "\n" << e2 << " evaluates to " << v2
|
|
||||||
<< "\n" << e3 << " evaluates to " << v3;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT3.
|
|
||||||
// Don't use this in your code.
|
|
||||||
#define GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, on_failure)\
|
|
||||||
GTEST_ASSERT_(pred_format(#v1, #v2, #v3, v1, v2, v3), \
|
|
||||||
on_failure)
|
|
||||||
|
|
||||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED3. Don't use
|
|
||||||
// this in your code.
|
|
||||||
#define GTEST_PRED3_(pred, v1, v2, v3, on_failure)\
|
|
||||||
GTEST_ASSERT_(::testing::AssertPred3Helper(#pred, \
|
|
||||||
#v1, \
|
|
||||||
#v2, \
|
|
||||||
#v3, \
|
|
||||||
pred, \
|
|
||||||
v1, \
|
|
||||||
v2, \
|
|
||||||
v3), on_failure)
|
|
||||||
|
|
||||||
// Ternary predicate assertion macros.
|
|
||||||
#define EXPECT_PRED_FORMAT3(pred_format, v1, v2, v3) \
|
|
||||||
GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_NONFATAL_FAILURE_)
|
|
||||||
#define EXPECT_PRED3(pred, v1, v2, v3) \
|
|
||||||
GTEST_PRED3_(pred, v1, v2, v3, GTEST_NONFATAL_FAILURE_)
|
|
||||||
#define ASSERT_PRED_FORMAT3(pred_format, v1, v2, v3) \
|
|
||||||
GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_FATAL_FAILURE_)
|
|
||||||
#define ASSERT_PRED3(pred, v1, v2, v3) \
|
|
||||||
GTEST_PRED3_(pred, v1, v2, v3, GTEST_FATAL_FAILURE_)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Helper function for implementing {EXPECT|ASSERT}_PRED4. Don't use
|
|
||||||
// this in your code.
|
|
||||||
template <typename Pred,
|
|
||||||
typename T1,
|
|
||||||
typename T2,
|
|
||||||
typename T3,
|
|
||||||
typename T4>
|
|
||||||
AssertionResult AssertPred4Helper(const char* pred_text,
|
|
||||||
const char* e1,
|
|
||||||
const char* e2,
|
|
||||||
const char* e3,
|
|
||||||
const char* e4,
|
|
||||||
Pred pred,
|
|
||||||
const T1& v1,
|
|
||||||
const T2& v2,
|
|
||||||
const T3& v3,
|
|
||||||
const T4& v4) {
|
|
||||||
if (pred(v1, v2, v3, v4)) return AssertionSuccess();
|
|
||||||
|
|
||||||
return AssertionFailure() << pred_text << "("
|
|
||||||
<< e1 << ", "
|
|
||||||
<< e2 << ", "
|
|
||||||
<< e3 << ", "
|
|
||||||
<< e4 << ") evaluates to false, where"
|
|
||||||
<< "\n" << e1 << " evaluates to " << v1
|
|
||||||
<< "\n" << e2 << " evaluates to " << v2
|
|
||||||
<< "\n" << e3 << " evaluates to " << v3
|
|
||||||
<< "\n" << e4 << " evaluates to " << v4;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT4.
|
|
||||||
// Don't use this in your code.
|
|
||||||
#define GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, on_failure)\
|
|
||||||
GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, v1, v2, v3, v4), \
|
|
||||||
on_failure)
|
|
||||||
|
|
||||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED4. Don't use
|
|
||||||
// this in your code.
|
|
||||||
#define GTEST_PRED4_(pred, v1, v2, v3, v4, on_failure)\
|
|
||||||
GTEST_ASSERT_(::testing::AssertPred4Helper(#pred, \
|
|
||||||
#v1, \
|
|
||||||
#v2, \
|
|
||||||
#v3, \
|
|
||||||
#v4, \
|
|
||||||
pred, \
|
|
||||||
v1, \
|
|
||||||
v2, \
|
|
||||||
v3, \
|
|
||||||
v4), on_failure)
|
|
||||||
|
|
||||||
// 4-ary predicate assertion macros.
|
|
||||||
#define EXPECT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \
|
|
||||||
GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)
|
|
||||||
#define EXPECT_PRED4(pred, v1, v2, v3, v4) \
|
|
||||||
GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)
|
|
||||||
#define ASSERT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \
|
|
||||||
GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)
|
|
||||||
#define ASSERT_PRED4(pred, v1, v2, v3, v4) \
|
|
||||||
GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Helper function for implementing {EXPECT|ASSERT}_PRED5. Don't use
|
|
||||||
// this in your code.
|
|
||||||
template <typename Pred,
|
|
||||||
typename T1,
|
|
||||||
typename T2,
|
|
||||||
typename T3,
|
|
||||||
typename T4,
|
|
||||||
typename T5>
|
|
||||||
AssertionResult AssertPred5Helper(const char* pred_text,
|
|
||||||
const char* e1,
|
|
||||||
const char* e2,
|
|
||||||
const char* e3,
|
|
||||||
const char* e4,
|
|
||||||
const char* e5,
|
|
||||||
Pred pred,
|
|
||||||
const T1& v1,
|
|
||||||
const T2& v2,
|
|
||||||
const T3& v3,
|
|
||||||
const T4& v4,
|
|
||||||
const T5& v5) {
|
|
||||||
if (pred(v1, v2, v3, v4, v5)) return AssertionSuccess();
|
|
||||||
|
|
||||||
return AssertionFailure() << pred_text << "("
|
|
||||||
<< e1 << ", "
|
|
||||||
<< e2 << ", "
|
|
||||||
<< e3 << ", "
|
|
||||||
<< e4 << ", "
|
|
||||||
<< e5 << ") evaluates to false, where"
|
|
||||||
<< "\n" << e1 << " evaluates to " << v1
|
|
||||||
<< "\n" << e2 << " evaluates to " << v2
|
|
||||||
<< "\n" << e3 << " evaluates to " << v3
|
|
||||||
<< "\n" << e4 << " evaluates to " << v4
|
|
||||||
<< "\n" << e5 << " evaluates to " << v5;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT5.
|
|
||||||
// Don't use this in your code.
|
|
||||||
#define GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, on_failure)\
|
|
||||||
GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, #v5, v1, v2, v3, v4, v5), \
|
|
||||||
on_failure)
|
|
||||||
|
|
||||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED5. Don't use
|
|
||||||
// this in your code.
|
|
||||||
#define GTEST_PRED5_(pred, v1, v2, v3, v4, v5, on_failure)\
|
|
||||||
GTEST_ASSERT_(::testing::AssertPred5Helper(#pred, \
|
|
||||||
#v1, \
|
|
||||||
#v2, \
|
|
||||||
#v3, \
|
|
||||||
#v4, \
|
|
||||||
#v5, \
|
|
||||||
pred, \
|
|
||||||
v1, \
|
|
||||||
v2, \
|
|
||||||
v3, \
|
|
||||||
v4, \
|
|
||||||
v5), on_failure)
|
|
||||||
|
|
||||||
// 5-ary predicate assertion macros.
|
|
||||||
#define EXPECT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \
|
|
||||||
GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)
|
|
||||||
#define EXPECT_PRED5(pred, v1, v2, v3, v4, v5) \
|
|
||||||
GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)
|
|
||||||
#define ASSERT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \
|
|
||||||
GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)
|
|
||||||
#define ASSERT_PRED5(pred, v1, v2, v3, v4, v5) \
|
|
||||||
GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace testing
|
|
||||||
|
|
||||||
#endif // GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
// Copyright 2006, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
//
|
|
||||||
// Google C++ Testing and Mocking Framework definitions useful in production code.
|
|
||||||
// GOOGLETEST_CM0003 DO NOT DELETE
|
|
||||||
|
|
||||||
#ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_
|
|
||||||
#define GTEST_INCLUDE_GTEST_GTEST_PROD_H_
|
|
||||||
|
|
||||||
// When you need to test the private or protected members of a class,
|
|
||||||
// use the FRIEND_TEST macro to declare your tests as friends of the
|
|
||||||
// class. For example:
|
|
||||||
//
|
|
||||||
// class MyClass {
|
|
||||||
// private:
|
|
||||||
// void PrivateMethod();
|
|
||||||
// FRIEND_TEST(MyClassTest, PrivateMethodWorks);
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// class MyClassTest : public testing::Test {
|
|
||||||
// // ...
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// TEST_F(MyClassTest, PrivateMethodWorks) {
|
|
||||||
// // Can call MyClass::PrivateMethod() here.
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Note: The test class must be in the same namespace as the class being tested.
|
|
||||||
// For example, putting MyClassTest in an anonymous namespace will not work.
|
|
||||||
|
|
||||||
#define FRIEND_TEST(test_case_name, test_name)\
|
|
||||||
friend class test_case_name##_##test_name##_Test
|
|
||||||
|
|
||||||
#endif // GTEST_INCLUDE_GTEST_GTEST_PROD_H_
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
# Customization Points
|
|
||||||
|
|
||||||
The custom directory is an injection point for custom user configurations.
|
|
||||||
|
|
||||||
## Header `gtest.h`
|
|
||||||
|
|
||||||
### The following macros can be defined:
|
|
||||||
|
|
||||||
* `GTEST_OS_STACK_TRACE_GETTER_` - The name of an implementation of
|
|
||||||
`OsStackTraceGetterInterface`.
|
|
||||||
* `GTEST_CUSTOM_TEMPDIR_FUNCTION_` - An override for `testing::TempDir()`. See
|
|
||||||
`testing::TempDir` for semantics and signature.
|
|
||||||
|
|
||||||
## Header `gtest-port.h`
|
|
||||||
|
|
||||||
The following macros can be defined:
|
|
||||||
|
|
||||||
### Flag related macros:
|
|
||||||
|
|
||||||
* `GTEST_FLAG(flag_name)`
|
|
||||||
* `GTEST_USE_OWN_FLAGFILE_FLAG_` - Define to 0 when the system provides its
|
|
||||||
own flagfile flag parsing.
|
|
||||||
* `GTEST_DECLARE_bool_(name)`
|
|
||||||
* `GTEST_DECLARE_int32_(name)`
|
|
||||||
* `GTEST_DECLARE_string_(name)`
|
|
||||||
* `GTEST_DEFINE_bool_(name, default_val, doc)`
|
|
||||||
* `GTEST_DEFINE_int32_(name, default_val, doc)`
|
|
||||||
* `GTEST_DEFINE_string_(name, default_val, doc)`
|
|
||||||
|
|
||||||
### Logging:
|
|
||||||
|
|
||||||
* `GTEST_LOG_(severity)`
|
|
||||||
* `GTEST_CHECK_(condition)`
|
|
||||||
* Functions `LogToStderr()` and `FlushInfoLog()` have to be provided too.
|
|
||||||
|
|
||||||
### Threading:
|
|
||||||
|
|
||||||
* `GTEST_HAS_NOTIFICATION_` - Enabled if Notification is already provided.
|
|
||||||
* `GTEST_HAS_MUTEX_AND_THREAD_LOCAL_` - Enabled if `Mutex` and `ThreadLocal`
|
|
||||||
are already provided. Must also provide `GTEST_DECLARE_STATIC_MUTEX_(mutex)`
|
|
||||||
and `GTEST_DEFINE_STATIC_MUTEX_(mutex)`
|
|
||||||
* `GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)`
|
|
||||||
* `GTEST_LOCK_EXCLUDED_(locks)`
|
|
||||||
|
|
||||||
### Underlying library support features
|
|
||||||
|
|
||||||
* `GTEST_HAS_CXXABI_H_`
|
|
||||||
|
|
||||||
### Exporting API symbols:
|
|
||||||
|
|
||||||
* `GTEST_API_` - Specifier for exported symbols.
|
|
||||||
|
|
||||||
## Header `gtest-printers.h`
|
|
||||||
|
|
||||||
* See documentation at `gtest/gtest-printers.h` for details on how to define a
|
|
||||||
custom printer.
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
// Copyright 2015, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
//
|
|
||||||
// Injection point for custom user configurations. See README for details
|
|
||||||
//
|
|
||||||
// ** Custom implementation starts here **
|
|
||||||
|
|
||||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_
|
|
||||||
#define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_
|
|
||||||
|
|
||||||
#endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
// Copyright 2015, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
//
|
|
||||||
// This file provides an injection point for custom printers in a local
|
|
||||||
// installation of gTest.
|
|
||||||
// It will be included from gtest-printers.h and the overrides in this file
|
|
||||||
// will be visible to everyone.
|
|
||||||
//
|
|
||||||
// Injection point for custom user configurations. See README for details
|
|
||||||
//
|
|
||||||
// ** Custom implementation starts here **
|
|
||||||
|
|
||||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_
|
|
||||||
#define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_
|
|
||||||
|
|
||||||
#endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
// Copyright 2015, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
//
|
|
||||||
// Injection point for custom user configurations. See README for details
|
|
||||||
//
|
|
||||||
// ** Custom implementation starts here **
|
|
||||||
|
|
||||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_
|
|
||||||
#define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_
|
|
||||||
|
|
||||||
#endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_
|
|
||||||
@@ -1,280 +0,0 @@
|
|||||||
// Copyright 2005, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
//
|
|
||||||
// The Google C++ Testing and Mocking Framework (Google Test)
|
|
||||||
//
|
|
||||||
// This header file defines internal utilities needed for implementing
|
|
||||||
// death tests. They are subject to change without notice.
|
|
||||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
|
||||||
|
|
||||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
|
|
||||||
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
|
|
||||||
|
|
||||||
#include "gtest/internal/gtest-internal.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
namespace testing {
|
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
GTEST_DECLARE_string_(internal_run_death_test);
|
|
||||||
|
|
||||||
// Names of the flags (needed for parsing Google Test flags).
|
|
||||||
const char kDeathTestStyleFlag[] = "death_test_style";
|
|
||||||
const char kDeathTestUseFork[] = "death_test_use_fork";
|
|
||||||
const char kInternalRunDeathTestFlag[] = "internal_run_death_test";
|
|
||||||
|
|
||||||
#if GTEST_HAS_DEATH_TEST
|
|
||||||
|
|
||||||
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
|
|
||||||
/* class A needs to have dll-interface to be used by clients of class B */)
|
|
||||||
|
|
||||||
// DeathTest is a class that hides much of the complexity of the
|
|
||||||
// GTEST_DEATH_TEST_ macro. It is abstract; its static Create method
|
|
||||||
// returns a concrete class that depends on the prevailing death test
|
|
||||||
// style, as defined by the --gtest_death_test_style and/or
|
|
||||||
// --gtest_internal_run_death_test flags.
|
|
||||||
|
|
||||||
// In describing the results of death tests, these terms are used with
|
|
||||||
// the corresponding definitions:
|
|
||||||
//
|
|
||||||
// exit status: The integer exit information in the format specified
|
|
||||||
// by wait(2)
|
|
||||||
// exit code: The integer code passed to exit(3), _exit(2), or
|
|
||||||
// returned from main()
|
|
||||||
class GTEST_API_ DeathTest {
|
|
||||||
public:
|
|
||||||
// Create returns false if there was an error determining the
|
|
||||||
// appropriate action to take for the current death test; for example,
|
|
||||||
// if the gtest_death_test_style flag is set to an invalid value.
|
|
||||||
// The LastMessage method will return a more detailed message in that
|
|
||||||
// case. Otherwise, the DeathTest pointer pointed to by the "test"
|
|
||||||
// argument is set. If the death test should be skipped, the pointer
|
|
||||||
// is set to NULL; otherwise, it is set to the address of a new concrete
|
|
||||||
// DeathTest object that controls the execution of the current test.
|
|
||||||
static bool Create(const char* statement, const RE* regex,
|
|
||||||
const char* file, int line, DeathTest** test);
|
|
||||||
DeathTest();
|
|
||||||
virtual ~DeathTest() { }
|
|
||||||
|
|
||||||
// A helper class that aborts a death test when it's deleted.
|
|
||||||
class ReturnSentinel {
|
|
||||||
public:
|
|
||||||
explicit ReturnSentinel(DeathTest* test) : test_(test) { }
|
|
||||||
~ReturnSentinel() { test_->Abort(TEST_ENCOUNTERED_RETURN_STATEMENT); }
|
|
||||||
private:
|
|
||||||
DeathTest* const test_;
|
|
||||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(ReturnSentinel);
|
|
||||||
} GTEST_ATTRIBUTE_UNUSED_;
|
|
||||||
|
|
||||||
// An enumeration of possible roles that may be taken when a death
|
|
||||||
// test is encountered. EXECUTE means that the death test logic should
|
|
||||||
// be executed immediately. OVERSEE means that the program should prepare
|
|
||||||
// the appropriate environment for a child process to execute the death
|
|
||||||
// test, then wait for it to complete.
|
|
||||||
enum TestRole { OVERSEE_TEST, EXECUTE_TEST };
|
|
||||||
|
|
||||||
// An enumeration of the three reasons that a test might be aborted.
|
|
||||||
enum AbortReason {
|
|
||||||
TEST_ENCOUNTERED_RETURN_STATEMENT,
|
|
||||||
TEST_THREW_EXCEPTION,
|
|
||||||
TEST_DID_NOT_DIE
|
|
||||||
};
|
|
||||||
|
|
||||||
// Assumes one of the above roles.
|
|
||||||
virtual TestRole AssumeRole() = 0;
|
|
||||||
|
|
||||||
// Waits for the death test to finish and returns its status.
|
|
||||||
virtual int Wait() = 0;
|
|
||||||
|
|
||||||
// Returns true if the death test passed; that is, the test process
|
|
||||||
// exited during the test, its exit status matches a user-supplied
|
|
||||||
// predicate, and its stderr output matches a user-supplied regular
|
|
||||||
// expression.
|
|
||||||
// The user-supplied predicate may be a macro expression rather
|
|
||||||
// than a function pointer or functor, or else Wait and Passed could
|
|
||||||
// be combined.
|
|
||||||
virtual bool Passed(bool exit_status_ok) = 0;
|
|
||||||
|
|
||||||
// Signals that the death test did not die as expected.
|
|
||||||
virtual void Abort(AbortReason reason) = 0;
|
|
||||||
|
|
||||||
// Returns a human-readable outcome message regarding the outcome of
|
|
||||||
// the last death test.
|
|
||||||
static const char* LastMessage();
|
|
||||||
|
|
||||||
static void set_last_death_test_message(const std::string& message);
|
|
||||||
|
|
||||||
private:
|
|
||||||
// A string containing a description of the outcome of the last death test.
|
|
||||||
static std::string last_death_test_message_;
|
|
||||||
|
|
||||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(DeathTest);
|
|
||||||
};
|
|
||||||
|
|
||||||
GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
|
|
||||||
|
|
||||||
// Factory interface for death tests. May be mocked out for testing.
|
|
||||||
class DeathTestFactory {
|
|
||||||
public:
|
|
||||||
virtual ~DeathTestFactory() { }
|
|
||||||
virtual bool Create(const char* statement, const RE* regex,
|
|
||||||
const char* file, int line, DeathTest** test) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
// A concrete DeathTestFactory implementation for normal use.
|
|
||||||
class DefaultDeathTestFactory : public DeathTestFactory {
|
|
||||||
public:
|
|
||||||
virtual bool Create(const char* statement, const RE* regex,
|
|
||||||
const char* file, int line, DeathTest** test);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Returns true if exit_status describes a process that was terminated
|
|
||||||
// by a signal, or exited normally with a nonzero exit code.
|
|
||||||
GTEST_API_ bool ExitedUnsuccessfully(int exit_status);
|
|
||||||
|
|
||||||
// Traps C++ exceptions escaping statement and reports them as test
|
|
||||||
// failures. Note that trapping SEH exceptions is not implemented here.
|
|
||||||
# if GTEST_HAS_EXCEPTIONS
|
|
||||||
# define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
|
|
||||||
try { \
|
|
||||||
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
|
|
||||||
} catch (const ::std::exception& gtest_exception) { \
|
|
||||||
fprintf(\
|
|
||||||
stderr, \
|
|
||||||
"\n%s: Caught std::exception-derived exception escaping the " \
|
|
||||||
"death test statement. Exception message: %s\n", \
|
|
||||||
::testing::internal::FormatFileLocation(__FILE__, __LINE__).c_str(), \
|
|
||||||
gtest_exception.what()); \
|
|
||||||
fflush(stderr); \
|
|
||||||
death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
|
|
||||||
} catch (...) { \
|
|
||||||
death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
|
|
||||||
}
|
|
||||||
|
|
||||||
# else
|
|
||||||
# define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
|
|
||||||
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)
|
|
||||||
|
|
||||||
# endif
|
|
||||||
|
|
||||||
// This macro is for implementing ASSERT_DEATH*, EXPECT_DEATH*,
|
|
||||||
// ASSERT_EXIT*, and EXPECT_EXIT*.
|
|
||||||
# define GTEST_DEATH_TEST_(statement, predicate, regex, fail) \
|
|
||||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
|
||||||
if (::testing::internal::AlwaysTrue()) { \
|
|
||||||
const ::testing::internal::RE& gtest_regex = (regex); \
|
|
||||||
::testing::internal::DeathTest* gtest_dt; \
|
|
||||||
if (!::testing::internal::DeathTest::Create(#statement, >est_regex, \
|
|
||||||
__FILE__, __LINE__, >est_dt)) { \
|
|
||||||
goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \
|
|
||||||
} \
|
|
||||||
if (gtest_dt != NULL) { \
|
|
||||||
::testing::internal::scoped_ptr< ::testing::internal::DeathTest> \
|
|
||||||
gtest_dt_ptr(gtest_dt); \
|
|
||||||
switch (gtest_dt->AssumeRole()) { \
|
|
||||||
case ::testing::internal::DeathTest::OVERSEE_TEST: \
|
|
||||||
if (!gtest_dt->Passed(predicate(gtest_dt->Wait()))) { \
|
|
||||||
goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \
|
|
||||||
} \
|
|
||||||
break; \
|
|
||||||
case ::testing::internal::DeathTest::EXECUTE_TEST: { \
|
|
||||||
::testing::internal::DeathTest::ReturnSentinel \
|
|
||||||
gtest_sentinel(gtest_dt); \
|
|
||||||
GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, gtest_dt); \
|
|
||||||
gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); \
|
|
||||||
break; \
|
|
||||||
} \
|
|
||||||
default: \
|
|
||||||
break; \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
} else \
|
|
||||||
GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__): \
|
|
||||||
fail(::testing::internal::DeathTest::LastMessage())
|
|
||||||
// The symbol "fail" here expands to something into which a message
|
|
||||||
// can be streamed.
|
|
||||||
|
|
||||||
// This macro is for implementing ASSERT/EXPECT_DEBUG_DEATH when compiled in
|
|
||||||
// NDEBUG mode. In this case we need the statements to be executed and the macro
|
|
||||||
// must accept a streamed message even though the message is never printed.
|
|
||||||
// The regex object is not evaluated, but it is used to prevent "unused"
|
|
||||||
// warnings and to avoid an expression that doesn't compile in debug mode.
|
|
||||||
#define GTEST_EXECUTE_STATEMENT_(statement, regex) \
|
|
||||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
|
||||||
if (::testing::internal::AlwaysTrue()) { \
|
|
||||||
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
|
|
||||||
} else if (!::testing::internal::AlwaysTrue()) { \
|
|
||||||
const ::testing::internal::RE& gtest_regex = (regex); \
|
|
||||||
static_cast<void>(gtest_regex); \
|
|
||||||
} else \
|
|
||||||
::testing::Message()
|
|
||||||
|
|
||||||
// A class representing the parsed contents of the
|
|
||||||
// --gtest_internal_run_death_test flag, as it existed when
|
|
||||||
// RUN_ALL_TESTS was called.
|
|
||||||
class InternalRunDeathTestFlag {
|
|
||||||
public:
|
|
||||||
InternalRunDeathTestFlag(const std::string& a_file,
|
|
||||||
int a_line,
|
|
||||||
int an_index,
|
|
||||||
int a_write_fd)
|
|
||||||
: file_(a_file), line_(a_line), index_(an_index),
|
|
||||||
write_fd_(a_write_fd) {}
|
|
||||||
|
|
||||||
~InternalRunDeathTestFlag() {
|
|
||||||
if (write_fd_ >= 0)
|
|
||||||
posix::Close(write_fd_);
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string& file() const { return file_; }
|
|
||||||
int line() const { return line_; }
|
|
||||||
int index() const { return index_; }
|
|
||||||
int write_fd() const { return write_fd_; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string file_;
|
|
||||||
int line_;
|
|
||||||
int index_;
|
|
||||||
int write_fd_;
|
|
||||||
|
|
||||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(InternalRunDeathTestFlag);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Returns a newly created InternalRunDeathTestFlag object with fields
|
|
||||||
// initialized from the GTEST_FLAG(internal_run_death_test) flag if
|
|
||||||
// the flag is specified; otherwise returns NULL.
|
|
||||||
InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag();
|
|
||||||
|
|
||||||
#endif // GTEST_HAS_DEATH_TEST
|
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
} // namespace testing
|
|
||||||
|
|
||||||
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
|
|
||||||
@@ -1,211 +0,0 @@
|
|||||||
// Copyright 2008, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
//
|
|
||||||
// Google Test filepath utilities
|
|
||||||
//
|
|
||||||
// This header file declares classes and functions used internally by
|
|
||||||
// Google Test. They are subject to change without notice.
|
|
||||||
//
|
|
||||||
// This file is #included in gtest/internal/gtest-internal.h.
|
|
||||||
// Do not include this header file separately!
|
|
||||||
|
|
||||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
|
||||||
|
|
||||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
|
|
||||||
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
|
|
||||||
|
|
||||||
#include "gtest/internal/gtest-string.h"
|
|
||||||
|
|
||||||
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
|
|
||||||
/* class A needs to have dll-interface to be used by clients of class B */)
|
|
||||||
|
|
||||||
namespace testing {
|
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
// FilePath - a class for file and directory pathname manipulation which
|
|
||||||
// handles platform-specific conventions (like the pathname separator).
|
|
||||||
// Used for helper functions for naming files in a directory for xml output.
|
|
||||||
// Except for Set methods, all methods are const or static, which provides an
|
|
||||||
// "immutable value object" -- useful for peace of mind.
|
|
||||||
// A FilePath with a value ending in a path separator ("like/this/") represents
|
|
||||||
// a directory, otherwise it is assumed to represent a file. In either case,
|
|
||||||
// it may or may not represent an actual file or directory in the file system.
|
|
||||||
// Names are NOT checked for syntax correctness -- no checking for illegal
|
|
||||||
// characters, malformed paths, etc.
|
|
||||||
|
|
||||||
class GTEST_API_ FilePath {
|
|
||||||
public:
|
|
||||||
FilePath() : pathname_("") { }
|
|
||||||
FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) { }
|
|
||||||
|
|
||||||
explicit FilePath(const std::string& pathname) : pathname_(pathname) {
|
|
||||||
Normalize();
|
|
||||||
}
|
|
||||||
|
|
||||||
FilePath& operator=(const FilePath& rhs) {
|
|
||||||
Set(rhs);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Set(const FilePath& rhs) {
|
|
||||||
pathname_ = rhs.pathname_;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string& string() const { return pathname_; }
|
|
||||||
const char* c_str() const { return pathname_.c_str(); }
|
|
||||||
|
|
||||||
// Returns the current working directory, or "" if unsuccessful.
|
|
||||||
static FilePath GetCurrentDir();
|
|
||||||
|
|
||||||
// Given directory = "dir", base_name = "test", number = 0,
|
|
||||||
// extension = "xml", returns "dir/test.xml". If number is greater
|
|
||||||
// than zero (e.g., 12), returns "dir/test_12.xml".
|
|
||||||
// On Windows platform, uses \ as the separator rather than /.
|
|
||||||
static FilePath MakeFileName(const FilePath& directory,
|
|
||||||
const FilePath& base_name,
|
|
||||||
int number,
|
|
||||||
const char* extension);
|
|
||||||
|
|
||||||
// Given directory = "dir", relative_path = "test.xml",
|
|
||||||
// returns "dir/test.xml".
|
|
||||||
// On Windows, uses \ as the separator rather than /.
|
|
||||||
static FilePath ConcatPaths(const FilePath& directory,
|
|
||||||
const FilePath& relative_path);
|
|
||||||
|
|
||||||
// Returns a pathname for a file that does not currently exist. The pathname
|
|
||||||
// will be directory/base_name.extension or
|
|
||||||
// directory/base_name_<number>.extension if directory/base_name.extension
|
|
||||||
// already exists. The number will be incremented until a pathname is found
|
|
||||||
// that does not already exist.
|
|
||||||
// Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'.
|
|
||||||
// There could be a race condition if two or more processes are calling this
|
|
||||||
// function at the same time -- they could both pick the same filename.
|
|
||||||
static FilePath GenerateUniqueFileName(const FilePath& directory,
|
|
||||||
const FilePath& base_name,
|
|
||||||
const char* extension);
|
|
||||||
|
|
||||||
// Returns true iff the path is "".
|
|
||||||
bool IsEmpty() const { return pathname_.empty(); }
|
|
||||||
|
|
||||||
// If input name has a trailing separator character, removes it and returns
|
|
||||||
// the name, otherwise return the name string unmodified.
|
|
||||||
// On Windows platform, uses \ as the separator, other platforms use /.
|
|
||||||
FilePath RemoveTrailingPathSeparator() const;
|
|
||||||
|
|
||||||
// Returns a copy of the FilePath with the directory part removed.
|
|
||||||
// Example: FilePath("path/to/file").RemoveDirectoryName() returns
|
|
||||||
// FilePath("file"). If there is no directory part ("just_a_file"), it returns
|
|
||||||
// the FilePath unmodified. If there is no file part ("just_a_dir/") it
|
|
||||||
// returns an empty FilePath ("").
|
|
||||||
// On Windows platform, '\' is the path separator, otherwise it is '/'.
|
|
||||||
FilePath RemoveDirectoryName() const;
|
|
||||||
|
|
||||||
// RemoveFileName returns the directory path with the filename removed.
|
|
||||||
// Example: FilePath("path/to/file").RemoveFileName() returns "path/to/".
|
|
||||||
// If the FilePath is "a_file" or "/a_file", RemoveFileName returns
|
|
||||||
// FilePath("./") or, on Windows, FilePath(".\\"). If the filepath does
|
|
||||||
// not have a file, like "just/a/dir/", it returns the FilePath unmodified.
|
|
||||||
// On Windows platform, '\' is the path separator, otherwise it is '/'.
|
|
||||||
FilePath RemoveFileName() const;
|
|
||||||
|
|
||||||
// Returns a copy of the FilePath with the case-insensitive extension removed.
|
|
||||||
// Example: FilePath("dir/file.exe").RemoveExtension("EXE") returns
|
|
||||||
// FilePath("dir/file"). If a case-insensitive extension is not
|
|
||||||
// found, returns a copy of the original FilePath.
|
|
||||||
FilePath RemoveExtension(const char* extension) const;
|
|
||||||
|
|
||||||
// Creates directories so that path exists. Returns true if successful or if
|
|
||||||
// the directories already exist; returns false if unable to create
|
|
||||||
// directories for any reason. Will also return false if the FilePath does
|
|
||||||
// not represent a directory (that is, it doesn't end with a path separator).
|
|
||||||
bool CreateDirectoriesRecursively() const;
|
|
||||||
|
|
||||||
// Create the directory so that path exists. Returns true if successful or
|
|
||||||
// if the directory already exists; returns false if unable to create the
|
|
||||||
// directory for any reason, including if the parent directory does not
|
|
||||||
// exist. Not named "CreateDirectory" because that's a macro on Windows.
|
|
||||||
bool CreateFolder() const;
|
|
||||||
|
|
||||||
// Returns true if FilePath describes something in the file-system,
|
|
||||||
// either a file, directory, or whatever, and that something exists.
|
|
||||||
bool FileOrDirectoryExists() const;
|
|
||||||
|
|
||||||
// Returns true if pathname describes a directory in the file-system
|
|
||||||
// that exists.
|
|
||||||
bool DirectoryExists() const;
|
|
||||||
|
|
||||||
// Returns true if FilePath ends with a path separator, which indicates that
|
|
||||||
// it is intended to represent a directory. Returns false otherwise.
|
|
||||||
// This does NOT check that a directory (or file) actually exists.
|
|
||||||
bool IsDirectory() const;
|
|
||||||
|
|
||||||
// Returns true if pathname describes a root directory. (Windows has one
|
|
||||||
// root directory per disk drive.)
|
|
||||||
bool IsRootDirectory() const;
|
|
||||||
|
|
||||||
// Returns true if pathname describes an absolute path.
|
|
||||||
bool IsAbsolutePath() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Replaces multiple consecutive separators with a single separator.
|
|
||||||
// For example, "bar///foo" becomes "bar/foo". Does not eliminate other
|
|
||||||
// redundancies that might be in a pathname involving "." or "..".
|
|
||||||
//
|
|
||||||
// A pathname with multiple consecutive separators may occur either through
|
|
||||||
// user error or as a result of some scripts or APIs that generate a pathname
|
|
||||||
// with a trailing separator. On other platforms the same API or script
|
|
||||||
// may NOT generate a pathname with a trailing "/". Then elsewhere that
|
|
||||||
// pathname may have another "/" and pathname components added to it,
|
|
||||||
// without checking for the separator already being there.
|
|
||||||
// The script language and operating system may allow paths like "foo//bar"
|
|
||||||
// but some of the functions in FilePath will not handle that correctly. In
|
|
||||||
// particular, RemoveTrailingPathSeparator() only removes one separator, and
|
|
||||||
// it is called in CreateDirectoriesRecursively() assuming that it will change
|
|
||||||
// a pathname from directory syntax (trailing separator) to filename syntax.
|
|
||||||
//
|
|
||||||
// On Windows this method also replaces the alternate path separator '/' with
|
|
||||||
// the primary path separator '\\', so that for example "bar\\/\\foo" becomes
|
|
||||||
// "bar\\foo".
|
|
||||||
|
|
||||||
void Normalize();
|
|
||||||
|
|
||||||
// Returns a pointer to the last occurence of a valid path separator in
|
|
||||||
// the FilePath. On Windows, for example, both '/' and '\' are valid path
|
|
||||||
// separators. Returns NULL if no path separator was found.
|
|
||||||
const char* FindLastPathSeparator() const;
|
|
||||||
|
|
||||||
std::string pathname_;
|
|
||||||
}; // class FilePath
|
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
} // namespace testing
|
|
||||||
|
|
||||||
GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
|
|
||||||
|
|
||||||
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,243 +0,0 @@
|
|||||||
// Copyright 2003 Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
//
|
|
||||||
// A "smart" pointer type with reference tracking. Every pointer to a
|
|
||||||
// particular object is kept on a circular linked list. When the last pointer
|
|
||||||
// to an object is destroyed or reassigned, the object is deleted.
|
|
||||||
//
|
|
||||||
// Used properly, this deletes the object when the last reference goes away.
|
|
||||||
// There are several caveats:
|
|
||||||
// - Like all reference counting schemes, cycles lead to leaks.
|
|
||||||
// - Each smart pointer is actually two pointers (8 bytes instead of 4).
|
|
||||||
// - Every time a pointer is assigned, the entire list of pointers to that
|
|
||||||
// object is traversed. This class is therefore NOT SUITABLE when there
|
|
||||||
// will often be more than two or three pointers to a particular object.
|
|
||||||
// - References are only tracked as long as linked_ptr<> objects are copied.
|
|
||||||
// If a linked_ptr<> is converted to a raw pointer and back, BAD THINGS
|
|
||||||
// will happen (double deletion).
|
|
||||||
//
|
|
||||||
// A good use of this class is storing object references in STL containers.
|
|
||||||
// You can safely put linked_ptr<> in a vector<>.
|
|
||||||
// Other uses may not be as good.
|
|
||||||
//
|
|
||||||
// Note: If you use an incomplete type with linked_ptr<>, the class
|
|
||||||
// *containing* linked_ptr<> must have a constructor and destructor (even
|
|
||||||
// if they do nothing!).
|
|
||||||
//
|
|
||||||
// Bill Gibbons suggested we use something like this.
|
|
||||||
//
|
|
||||||
// Thread Safety:
|
|
||||||
// Unlike other linked_ptr implementations, in this implementation
|
|
||||||
// a linked_ptr object is thread-safe in the sense that:
|
|
||||||
// - it's safe to copy linked_ptr objects concurrently,
|
|
||||||
// - it's safe to copy *from* a linked_ptr and read its underlying
|
|
||||||
// raw pointer (e.g. via get()) concurrently, and
|
|
||||||
// - it's safe to write to two linked_ptrs that point to the same
|
|
||||||
// shared object concurrently.
|
|
||||||
// FIXME: rename this to safe_linked_ptr to avoid
|
|
||||||
// confusion with normal linked_ptr.
|
|
||||||
|
|
||||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
|
||||||
|
|
||||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_
|
|
||||||
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include "gtest/internal/gtest-port.h"
|
|
||||||
|
|
||||||
namespace testing {
|
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
// Protects copying of all linked_ptr objects.
|
|
||||||
GTEST_API_ GTEST_DECLARE_STATIC_MUTEX_(g_linked_ptr_mutex);
|
|
||||||
|
|
||||||
// This is used internally by all instances of linked_ptr<>. It needs to be
|
|
||||||
// a non-template class because different types of linked_ptr<> can refer to
|
|
||||||
// the same object (linked_ptr<Superclass>(obj) vs linked_ptr<Subclass>(obj)).
|
|
||||||
// So, it needs to be possible for different types of linked_ptr to participate
|
|
||||||
// in the same circular linked list, so we need a single class type here.
|
|
||||||
//
|
|
||||||
// DO NOT USE THIS CLASS DIRECTLY YOURSELF. Use linked_ptr<T>.
|
|
||||||
class linked_ptr_internal {
|
|
||||||
public:
|
|
||||||
// Create a new circle that includes only this instance.
|
|
||||||
void join_new() {
|
|
||||||
next_ = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Many linked_ptr operations may change p.link_ for some linked_ptr
|
|
||||||
// variable p in the same circle as this object. Therefore we need
|
|
||||||
// to prevent two such operations from occurring concurrently.
|
|
||||||
//
|
|
||||||
// Note that different types of linked_ptr objects can coexist in a
|
|
||||||
// circle (e.g. linked_ptr<Base>, linked_ptr<Derived1>, and
|
|
||||||
// linked_ptr<Derived2>). Therefore we must use a single mutex to
|
|
||||||
// protect all linked_ptr objects. This can create serious
|
|
||||||
// contention in production code, but is acceptable in a testing
|
|
||||||
// framework.
|
|
||||||
|
|
||||||
// Join an existing circle.
|
|
||||||
void join(linked_ptr_internal const* ptr)
|
|
||||||
GTEST_LOCK_EXCLUDED_(g_linked_ptr_mutex) {
|
|
||||||
MutexLock lock(&g_linked_ptr_mutex);
|
|
||||||
|
|
||||||
linked_ptr_internal const* p = ptr;
|
|
||||||
while (p->next_ != ptr) {
|
|
||||||
assert(p->next_ != this &&
|
|
||||||
"Trying to join() a linked ring we are already in. "
|
|
||||||
"Is GMock thread safety enabled?");
|
|
||||||
p = p->next_;
|
|
||||||
}
|
|
||||||
p->next_ = this;
|
|
||||||
next_ = ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Leave whatever circle we're part of. Returns true if we were the
|
|
||||||
// last member of the circle. Once this is done, you can join() another.
|
|
||||||
bool depart()
|
|
||||||
GTEST_LOCK_EXCLUDED_(g_linked_ptr_mutex) {
|
|
||||||
MutexLock lock(&g_linked_ptr_mutex);
|
|
||||||
|
|
||||||
if (next_ == this) return true;
|
|
||||||
linked_ptr_internal const* p = next_;
|
|
||||||
while (p->next_ != this) {
|
|
||||||
assert(p->next_ != next_ &&
|
|
||||||
"Trying to depart() a linked ring we are not in. "
|
|
||||||
"Is GMock thread safety enabled?");
|
|
||||||
p = p->next_;
|
|
||||||
}
|
|
||||||
p->next_ = next_;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
mutable linked_ptr_internal const* next_;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
class linked_ptr {
|
|
||||||
public:
|
|
||||||
typedef T element_type;
|
|
||||||
|
|
||||||
// Take over ownership of a raw pointer. This should happen as soon as
|
|
||||||
// possible after the object is created.
|
|
||||||
explicit linked_ptr(T* ptr = NULL) { capture(ptr); }
|
|
||||||
~linked_ptr() { depart(); }
|
|
||||||
|
|
||||||
// Copy an existing linked_ptr<>, adding ourselves to the list of references.
|
|
||||||
template <typename U> linked_ptr(linked_ptr<U> const& ptr) { copy(&ptr); }
|
|
||||||
linked_ptr(linked_ptr const& ptr) { // NOLINT
|
|
||||||
assert(&ptr != this);
|
|
||||||
copy(&ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assignment releases the old value and acquires the new.
|
|
||||||
template <typename U> linked_ptr& operator=(linked_ptr<U> const& ptr) {
|
|
||||||
depart();
|
|
||||||
copy(&ptr);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
linked_ptr& operator=(linked_ptr const& ptr) {
|
|
||||||
if (&ptr != this) {
|
|
||||||
depart();
|
|
||||||
copy(&ptr);
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Smart pointer members.
|
|
||||||
void reset(T* ptr = NULL) {
|
|
||||||
depart();
|
|
||||||
capture(ptr);
|
|
||||||
}
|
|
||||||
T* get() const { return value_; }
|
|
||||||
T* operator->() const { return value_; }
|
|
||||||
T& operator*() const { return *value_; }
|
|
||||||
|
|
||||||
bool operator==(T* p) const { return value_ == p; }
|
|
||||||
bool operator!=(T* p) const { return value_ != p; }
|
|
||||||
template <typename U>
|
|
||||||
bool operator==(linked_ptr<U> const& ptr) const {
|
|
||||||
return value_ == ptr.get();
|
|
||||||
}
|
|
||||||
template <typename U>
|
|
||||||
bool operator!=(linked_ptr<U> const& ptr) const {
|
|
||||||
return value_ != ptr.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
template <typename U>
|
|
||||||
friend class linked_ptr;
|
|
||||||
|
|
||||||
T* value_;
|
|
||||||
linked_ptr_internal link_;
|
|
||||||
|
|
||||||
void depart() {
|
|
||||||
if (link_.depart()) delete value_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void capture(T* ptr) {
|
|
||||||
value_ = ptr;
|
|
||||||
link_.join_new();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename U> void copy(linked_ptr<U> const* ptr) {
|
|
||||||
value_ = ptr->get();
|
|
||||||
if (value_)
|
|
||||||
link_.join(&ptr->link_);
|
|
||||||
else
|
|
||||||
link_.join_new();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T> inline
|
|
||||||
bool operator==(T* ptr, const linked_ptr<T>& x) {
|
|
||||||
return ptr == x.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T> inline
|
|
||||||
bool operator!=(T* ptr, const linked_ptr<T>& x) {
|
|
||||||
return ptr != x.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
// A function to convert T* into linked_ptr<T>
|
|
||||||
// Doing e.g. make_linked_ptr(new FooBarBaz<type>(arg)) is a shorter notation
|
|
||||||
// for linked_ptr<FooBarBaz<type> >(new FooBarBaz<type>(arg))
|
|
||||||
template <typename T>
|
|
||||||
linked_ptr<T> make_linked_ptr(T* ptr) {
|
|
||||||
return linked_ptr<T>(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
} // namespace testing
|
|
||||||
|
|
||||||
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user