11 2013 档案

摘要:上一篇:Google C++测试框架系列入门篇:第二章 开始一个新项目原始链接:Basic Concepts词汇表版本号:v_0.1基本概念使用GTest你肯定会接触到断言这个概念。断言是用来判断某个条件是否为真。一个断言的结果可以是通过,也可以是非致命失败或致命失败。如果发生了一个致命失败,当前函数就会立刻退出,不然函数还是会继续执行到正常结束。测试使用断言来判断测试代码的行为。如果测试崩溃了或者断言失败,那么这个测试就失败了,不然就是通过。一个测试用例包含一个或多个测试。你必须用测试用例把你的测试进行分组以反映测试代码的结构。当某个测试用例中的多个测试共享一些对象或程序时,你可以把这些对象 阅读全文
posted @ 2013-11-22 11:35 移山测试工作室黑灯老师 阅读(653) 评论(0) 推荐(0)
摘要:上一篇:Google C++测试框架系列入门篇:第一章 介绍:为什么使用GTest?原始链接:Setting up a New Test Project词汇表版本号:v_0.1开始一个新项目使用GTest编写测试程序,你必须先把GTest编译成一个库文件然后在你的测试程序中链接它。我们为主流的构建系统准备了一些现成的脚本:GTest根目录下的msvc/用于Visual Studio,xcode/用于Mac的Xcode,make/用于GNU make,codegear/用于Borland C++ Builder,另外还有autotools script(已淘汰)和CMakeLists用于CMak 阅读全文
posted @ 2013-11-22 11:07 移山测试工作室黑灯老师 阅读(669) 评论(0) 推荐(0)
摘要:上一篇:更多关于断言的知识原始链接:Teaching Google Test How to Print Your Values词汇表版本号:v_0.1让GTest学习打印自定义对象当一个断言比如EXPECT_EQ()失败时,GTest会打印它的参数来帮你调试。它依靠用户可扩展值打印机来实现此功能。这个打印机了解如何打印C++的内建类型,原生数组,STL容器和任何支持"namespace foo {class Bar { ... }; // We want Google Test to be able to print instances of this.// It's imp 阅读全文
posted @ 2013-11-21 18:19 移山测试工作室黑灯老师 阅读(4517) 评论(0) 推荐(0)
摘要:原始链接:Introduction: Why Google C++ Testing Framework?词汇表版本号:v_0.1介绍:为什么使用GTest?GTest帮助你写更好的C++测试代码。不管你在什么平台上工作,无论是Linux,Windows还是Mac,只要你使用C++,GTest就可以帮助你。对于什么是一个好的测试,GTest如何来帮助实现这个目标,我们的观点如下:测试必须是独立并且可重复的。如果某个测试的通过还是失败依赖于其它测试的执行结果,那么调试它将是非常困难的。GTest通过在不同的项目下分别执行测试使得它们相互隔离。当某个测试失败后,GTest允许你单独执行它以便快速调试 阅读全文
posted @ 2013-11-21 14:04 移山测试工作室黑灯老师 阅读(853) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/jump-game-ii/Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal is to reach the last index in the minimum number of jumps.For ex 阅读全文
posted @ 2013-11-21 13:40 移山测试工作室黑灯老师 阅读(685) 评论(0) 推荐(1)
摘要:原始链接:More Assertions词汇表现在你应该已经读完了入门篇并且会使用GTest来写测试。是时候来学一些新把戏了。这篇文档将教会你更多知识:用断言构造复杂的失败信息,传递致命失败,重用和加速你的test fixtures,以及在你的测试中使用不同的标志位。版本号:v_0.1更多关于断言的知识1. 明确的声明成功或失败2. 异常断言3. 通过谓词断言提供更好的错误信息3.1 使用已有的bool类型函数3.2 使用返回AssertionResult对象的函数3.3 使用格式化谓词4. 浮点数比较4.1 宏4.2 浮点数格式化谓词函数5. Windows平台处理HRESULT的断言6. 阅读全文
posted @ 2013-11-21 11:48 移山测试工作室黑灯老师 阅读(3799) 评论(1) 推荐(1)
摘要:版本号:v_0.1词汇表Assertion: 断言。Bug: 不翻译。Caveat: 警告。Error bound: 误差范围。Exception: 异常。Flag: 标志位。Floating point predicate format functions: 浮点数格式化谓词函数。Functor: 函数体。不懂的话Google,属于C++必知必会。Google Test/Google C++ Testing Framework: GTestHouse keeping chores: 家务杂事。这里指围绕测试代码编写很多非核心的支持性工作。Macro: 宏Message: 信息。Ostream 阅读全文
posted @ 2013-11-20 14:21 移山测试工作室黑灯老师 阅读(594) 评论(0) 推荐(0)
摘要:原始链接:V1_6_Primer注GTest或者Google Test: Google的C++测试框架。Test Fixtures: 这个词实在找不到对应的中文。Bug: 太常用了,不翻译。House keeping chores: 家常事务。指非核心的编码工作,比如测试代码的assert, log以及用例管理等工作。set-up/tear-down: 指运行测试前的准备和之后的清理工作。test case: 测试用例,管理测试的单位,一个测试用例可以包含一个或多个测试。在阅读之前,推荐阅读《为什么有如此多的C++测试框架 - from Google Testing Blog》了解一些背景知识 阅读全文
posted @ 2013-11-15 13:36 移山测试工作室黑灯老师 阅读(10234) 评论(1) 推荐(1)
摘要:http://oj.leetcode.com/problems/permutations-ii/Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[1,1,2], [1,2,1], and [2,1,1].思路:如果前面Permutations的问题已经解决了的话,这个问题就变得非常简单。先排个序,以[1, 1, 2]为例,第一 阅读全文
posted @ 2013-11-14 14:58 移山测试工作室黑灯老师 阅读(1588) 评论(1) 推荐(0)
摘要:http://oj.leetcode.com/problems/permutations/Given a collection of numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1].思路:典型的递归问题。生成[2, 3]的全排列[2, 3]和[3, 2],然后把1加上去生成[1, 2, 3]和[1, 3, 2]。交换1和2的位置,生成[1, 3 阅读全文
posted @ 2013-11-12 14:28 移山测试工作室黑灯老师 阅读(2571) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/wildcard-matching/Implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover the entire input string 阅读全文
posted @ 2013-11-11 17:52 移山测试工作室黑灯老师 阅读(807) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/multiply-strings/Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-negative.思路:这是一道经常出现的面试题。竖式乘法怎么做的照搬就可以,注意看代码,用一个string搞定。class Solution {public: string multiply(strin... 阅读全文
posted @ 2013-11-07 15:27 移山测试工作室黑灯老师 阅读(2041) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/trapping-rain-water/Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,2,1,2,1], return 6.The above elevation map is represented by a 阅读全文
posted @ 2013-11-07 15:09 移山测试工作室黑灯老师 阅读(1054) 评论(0) 推荐(1)
摘要:更多内容敬请期待。解法是否最优不能保证,但OJ肯定是能过的。1: Two Sum2:Median of Two Sorted Arrays3: Longest Substring Without Repeating Characters4:Add Two Numbers5:Longest Palindromic Substring6:ZigZag Conversion7:Reverse Integer8:String to Integer (atoi)9:Palindrome Number10:Regular Expression Matching11:Container With Most 阅读全文
posted @ 2013-11-06 10:22 移山测试工作室黑灯老师 阅读(952) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/first-missing-positive/Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses constant space.思路:显然排序数数的方法是不能用了。解决的思路很简单,我们要找的是第一个没有出现的正数,那么如果我们 阅读全文
posted @ 2013-11-06 10:08 移山测试工作室黑灯老师 阅读(430) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/combination-sum-ii/Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be used once in the combination.Note:All numbers (including target) will be positi 阅读全文
posted @ 2013-11-05 10:18 移山测试工作室黑灯老师 阅读(1339) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/combination-sum/Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited number of times.Note:All numbers (including target) will be po 阅读全文
posted @ 2013-11-04 18:11 移山测试工作室黑灯老师 阅读(805) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/count-and-say/The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read off as "one 2, then one 1" or 1211.Given an i 阅读全文
posted @ 2013-11-04 13:42 移山测试工作室黑灯老师 阅读(375) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/sudoku-solver/Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will be only one unique solution.A sudoku puzzle......and its solution numbers marked in red.思路:和前面一题Vali 阅读全文
posted @ 2013-11-04 10:55 移山测试工作室黑灯老师 阅读(3713) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/linked-list-cycle-ii/Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Follow up:Can you solve it without using extra space?思路:如果前面Linked List Cycle的问题已经解决,再扩展一下就可以了。如果一步走两步走的方法在某个点交汇了,那么这个点肯定在环内。那么算出环的长度n,令某个节点从head出发先走n步, 阅读全文
posted @ 2013-11-01 13:33 移山测试工作室黑灯老师 阅读(474) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/valid-sudoku/Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.A partially filled sudoku which is valid.思路:按行,按列,再按3 * 3小方块检查,只要都通过就返回true,不然 阅读全文
posted @ 2013-11-01 13:12 移山测试工作室黑灯老师 阅读(2778) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/search-insert-position/Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.Here are few examples.[1,3,5,6], 5 → 2[1,3,5,6], 阅读全文
posted @ 2013-11-01 12:52 移山测试工作室黑灯老师 阅读(260) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/search-for-a-range/Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the target is not found in the array, return [-1, -1].For example,Given [5, 7 阅读全文
posted @ 2013-11-01 11:52 移山测试工作室黑灯老师 阅读(404) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/search-in-rotated-sorted-array/Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array return its index, otherwise return -1.You may assume 阅读全文
posted @ 2013-11-01 11:11 移山测试工作室黑灯老师 阅读(599) 评论(0) 推荐(0)

count website visits
Buy Computers